I'm new to symfony. I found a project of a programmer and try to figure it out. And at once a dead end: when you enter the main one, she throws me on / login . Where can I find this redirect to remove? thank

  • Perhaps you should start parsing someone else's code with the file app / config / routing.yml - player0k
  • dealt with this file, but can routing be redirected? - Diefair
  • no, but there is indicated a controller in which it is probably worth forwarding, as well as in the config, you can specify routes for which authorization is required. And it would not be bad to make sure that there is no redirection in .htaccess, if the site is running on an Apache server - player0k
  • in htaccess there is nothing, and in what specific config to look? - Diefair
  • Here is what I found: if you delete this fos_user: resource: "@ FOSUserBundle / Resources / config / routing / all.xml" the site stops working. But the trouble is that I can not find the file all.xml - Diefair

2 answers 2

app / config / security.yml

Perhaps there is a url type protection:

access_control: - { path: ^/, roles: ROLE_ADMIN } 

And here passwords and logins:

 providers: 
    • You need to see how many "bundles" (Bundle) in the /src folder.
    • Each such Bundle package ends with the word Bundle.
    • In the bundles there is a controller (what you need), for example, if you have / src / TestBundle / Controller, then you need to watch a file (DefaultController.php) which in the Controller folder ends with the word ...Controller.php , where the controller file is located which handles the request.
    • You need to look at all the controllers in all bundles and see the Routes routes.

    something similar (for example) should be written above the function that processes your request:

      /** * @Route("/") */ public function index_catch() { ///////// ...... return $this->redirectToRoute('login'); } 

    return $this->redirectToRoute('login'); This is a redirect that can be implemented in different ways . The code with asterisks in symfony called annotation method route

    Here, in the example, I showed how a redirect in a symphony can be implemented. In older versions, the syntax may be different, but in any case, you need to look at the controller files. In your case, you need to view all the bundles and all controllers (at best, you will have one bundle in the /src folder and one controller file in it, but there may be many bundles in the /src folder which controllers need to be viewed). The top code should be in the same file with the following code (where other parameters can be Route ):

      /** * @Route("/login",name='login') */ public function index_catch() { ///////// ...... return $this->render('Bundle:Default:login.twig'); } 
    • looked through all the controllers - found nothing - Diefair
    • then maybe .htaccess file need to look. Or try typing Ctrl + F in your IDE and look for the header('Location: - fonjeekay
    • I wrote about .htaccess - there is nothing there. I did a search and found what I did - Diefair
    • public function testHandleExceptionWithARedirectionResponse(){ $dispatcher = new EventDispatcher(); $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { $event->setResponse(new RedirectResponse('/login', 301)); }); $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new AccessDeniedHttpException(); })); $response = $kernel->handle(new Request()); $this->assertEquals('301', $response->getStatusCode()); $this->assertEquals('/login', $response->headers->get('Location')); } public function testHandleExceptionWithARedirectionResponse(){ $dispatcher = new EventDispatcher(); $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { $event->setResponse(new RedirectResponse('/login', 301)); }); $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new AccessDeniedHttpException(); })); $response = $kernel->handle(new Request()); $this->assertEquals('301', $response->getStatusCode()); $this->assertEquals('/login', $response->headers->get('Location')); } - Diefair
    • only I do not understand what it is (( - Diefair