Fosuserbundle No routes found for "GET / login /"

I recently updated symfony2 using composer, and now I can not login. Here are the relevant files. Let me know if additional data is needed.

application / Config / routing.yml

app_admin: resource: "@AppAdminBundle/Resources/config/routing.yml" prefix: /admin host: dashboard.muchomonitor.com app_website: resource: "@AppWebsiteBundle/Resources/config/routing.yml" prefix: / host: www.muchomonitor.com app_monitor: resource: "@AppMonitorBundle/Resources/config/routing.yml" prefix: / host: dashboard.muchomonitor.com fos_user_security: resource: "@FOSUserBundle/Resources/config/routing/security.xml" host: dashboard.muchomonitor.com fos_user_security_reset: resource: "@FOSUserBundle/Resources/config/routing/resetting.xml" prefix: /login host: dashboard.muchomonitor.com 

application / Config / security.yml

 security: encoders: FOS\UserBundle\Model\UserInterface: sha512 role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: ROLE_ADMIN providers: fos_userbundle: id: fos_user.user_provider.username user: entity: { class: App\MonitorBundle\Entity\User, property: username } firewalls: main: pattern: ^/ provider: user form_login: provider: fos_userbundle csrf_provider: form.csrf_provider login_path: fos_user_security_login check_path: fos_user_security_check default_target_path: / logout: true anonymous: true logout: path: /logout target: /login access_control: - { path: ^/admin, role: ROLE_SUPER_ADMIN, host: dashboard.muchomonitor.com } - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY, host: dashboard.muchomonitor.com } - { path: ^/_, role: ROLE_ADMIN } # Development mode - { path: ^/public-status, role: IS_AUTHENTICATED_ANONYMOUSLY, host: dashboard.muchomonitor.com } - { path: ^/ipn, role: IS_AUTHENTICATED_ANONYMOUSLY, host: dashboard.muchomonitor.com } - { path: ^/invoice, role: IS_AUTHENTICATED_ANONYMOUSLY, host: dashboard.muchomonitor.com } - { path: ^/, role: ROLE_USER, host: dashboard.muchomonitor.com } 

seller / friendsofsymfony / custom package / FOS / UserBundle / Resources / configuration / routing / security.xml

 <?xml version="1.0" encoding="UTF-8" ?> <routes xmlns="http://symfony.com/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> <route id="fos_user_security_login" pattern="/login"> <default key="_controller">FOSUserBundle:Security:login</default> </route> <route id="fos_user_security_check" pattern="/login_check"> <default key="_controller">FOSUserBundle:Security:check</default> <requirement key="_method">POST</requirement> </route> <route id="fos_user_security_logout" pattern="/logout"> <default key="_controller">FOSUserBundle:Security:logout</default> </route> </routes> 

seller / friendsofsymfony / custom package / FOS / UserBundle / Resources / configuration / routing / resetting.xml

 <?xml version="1.0" encoding="UTF-8" ?> <routes xmlns="http://symfony.com/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> <route id="fos_user_resetting_request" pattern="/request"> <default key="_controller">FOSUserBundle:Resetting:request</default> <requirement key="_method">GET</requirement> </route> <route id="fos_user_resetting_send_email" pattern="/send-email"> <default key="_controller">FOSUserBundle:Resetting:sendEmail</default> <requirement key="_method">POST</requirement> </route> <route id="fos_user_resetting_check_email" pattern="/check-email"> <default key="_controller">FOSUserBundle:Resetting:checkEmail</default> <requirement key="_method">GET</requirement> </route> <route id="fos_user_resetting_reset" pattern="/reset/{token}"> <default key="_controller">FOSUserBundle:Resetting:reset</default> <requirement key="_method">GET|POST</requirement> </route> </routes> 

php app / console route: debug

 Name Method Scheme Host Path app_admin_users ANY ANY dashboard.muchomonitor.com /admin app_admin_add_user ANY ANY dashboard.muchomonitor.com /admin app_admin_edit_user ANY ANY dashboard.muchomonitor.com /admin app_admin_delete_user ANY ANY dashboard.muchomonitor.com /admin/user/{id}/delete app_admin_login_user ANY ANY dashboard.muchomonitor.com /admin/user/{id}/login app_admin_plans ANY ANY dashboard.muchomonitor.com /admin/plans app_admin_delete_plan ANY ANY dashboard.muchomonitor.com /admin/plans/{id}/delete app_admin_edit_plan ANY ANY dashboard.muchomonitor.com /admin/plans/{id}/edit app_admin_add_plan ANY ANY dashboard.muchomonitor.com /admin/plans/add app_admin_invoices ANY ANY dashboard.muchomonitor.com /admin/invoices app_admin_delete_invoice ANY ANY dashboard.muchomonitor.com /admin/invoices/{id}/delete app_admin_edit_invoice ANY ANY dashboard.muchomonitor.com /admin/invoices/{id}/edit app_admin_add_invoice ANY ANY dashboard.muchomonitor.com /admin/invoices/add app_website_index ANY ANY www.muchomonitor.com / app_website_pricing ANY ANY www.muchomonitor.com /pricing app_website_privacy_policy ANY ANY www.muchomonitor.com /legal/privacypolicy app_website_signup ANY ANY www.muchomonitor.com /signup app_website_tos ANY ANY www.muchomonitor.com /legal/termsofservice app_website_contact_us ANY ANY www.muchomonitor.com /contactus app_monitor_dashboard ANY ANY dashboard.muchomonitor.com / app_monitor_dashboard_search ANY ANY dashboard.muchomonitor.com /dashboard/search/{filter} app_monitor_dashboard_toggle ANY ANY dashboard.muchomonitor.com /dashboard/toggle/{monitor} app_monitor_dashboard_delete ANY ANY dashboard.muchomonitor.com /dashboard/delete app_monitor_dashboard_test ANY ANY dashboard.muchomonitor.com /dashboard/test app_monitor_monitors ANY ANY dashboard.muchomonitor.com /monitors app_monitor_monitors_edit ANY ANY dashboard.muchomonitor.com /monitors/edit/{monitor} app_monitor_monitors_new ANY ANY dashboard.muchomonitor.com /monitors/new app_monitor_monitors_toggle ANY ANY dashboard.muchomonitor.com /monitors/toggle/{monitor} app_monitor_monitors_delete ANY ANY dashboard.muchomonitor.com /monitors/delete app_monitor_monitors_test ANY ANY dashboard.muchomonitor.com /monitors/test app_monitor_report ANY ANY dashboard.muchomonitor.com /report app_monitor_reports ANY ANY dashboard.muchomonitor.com /report app_monitor_report_specific ANY ANY dashboard.muchomonitor.com /report/{monitor} app_monitor_accounts ANY ANY dashboard.muchomonitor.com /accounts app_monitor_accounts_edit ANY ANY dashboard.muchomonitor.com /accounts/edit/{id} app_monitor_accounts_new ANY ANY dashboard.muchomonitor.com /accounts/new app_monitor_accounts_delete ANY ANY dashboard.muchomonitor.com /accounts/delete app_monitor_billing ANY ANY dashboard.muchomonitor.com /billing app_monitor_billing_all ANY ANY dashboard.muchomonitor.com /billing/all app_monitor_billing_invoice ANY ANY dashboard.muchomonitor.com /invoice/{key}/{id} app_monitor_notifications ANY ANY dashboard.muchomonitor.com /notifications app_monitor_ipn ANY ANY dashboard.muchomonitor.com /ipn app_monitor_ipn_stripe ANY ANY dashboard.muchomonitor.com /ipn-stripe fos_user_security_login ANY ANY dashboard.muchomonitor.com /login fos_user_security_check POST ANY dashboard.muchomonitor.com /login_check fos_user_security_logout ANY ANY dashboard.muchomonitor.com /logout fos_user_resetting_request GET ANY dashboard.muchomonitor.com /login/request fos_user_resetting_send_email POST ANY dashboard.muchomonitor.com /login/send-email fos_user_resetting_check_email GET ANY dashboard.muchomonitor.com /login/check-email fos_user_resetting_reset GET|POST ANY dashboard.muchomonitor.com /login/reset/{token} 

going to dashboard.muchomonitor.com/login shows that it does not work, despite what is said above.

EDIT: I solved the problem. In routing.yml

 fos_user_security_login: pattern: /login/ defaults: { _controller: FOSUserBundle:Security:login } fos_user_security_check: pattern: /login_check defaults: { _controller: FOSUserBundle:Security:check } fos_user_security_logout: pattern: /logout defaults: { _controller: FOSUserBundle:Security:logout } 
+6
source share
2 answers

First of all ... your login login should (according to your current configuration) be /login , not /login/ .

The URL /login / (with a trailing slash) does not really have in your routing configuration.

The right way will allow the router to generate the URL using the route name, rather than hardcoding that url /login in any of your templates.

 {{ path('fos_user_security_login') }} 

Further ... Please read my answer here , which explains how <firewall>.login.check_path .

Change the primary firewall provider from user to fos_userbundle .

There is no additional provider configuration in the login_path section.

 firewalls: main: pattern: ^/ provider: fos_userbundle form_login: csrf_provider: form.csrf_provider login_path: fos_user_security_login check_path: fos_user_security_check default_target_path: app_website_index logout: path: fos_user_security_logout target: fos_user_security_login anonymous: true 

Next, you announced the exit to the firewall configuration twice (the second one is overwritten first):

 firewalls: # ... logout: true # ... logout: path: /logout target: /login 
+10
source

I had a similar problem, although I solved it differently (using Symfony 3.1, but maybe this is the same job).

When I executed the bin/console debug:router command in the console, I could see that the authentication routes provided by the User FoS package were correct and displayed correctly.

Now the problem is that in the console the standard environment was DEV, while from the browser it was PROD.

I ran the same command above, but explicitly passed the environment as follows:

bin/console debug:router --env=dev , and I got the same results as before.

But when executing bin/console debug:router --env=prod , I got an error in the console stating that the routing.yml file routing.yml not found.

That was right. I changed the structure of the app/config directory and created a folder for each environment with the corresponding files in each folder (much tidier configuration, IMHO).

But it seems that the path for routing.yml for the PROD environment is hard-coded for some providers (for example, vendor/sensio/generator-bundle/Command ), and because of this, the location of this file cannot be changed.

After reconfiguring the configuration folder, everything worked (but I needed to clear the PROD environment cache as follows: bin/console cache:clear --no-warmup --env=prod .

0
source

Source: https://habr.com/ru/post/957276/


All Articles