Symfony : Issue with routing -
i'm new symfony, follow tutorial, part security , user management i'm stucked problem seems come routing.
i created login form working, when go on /app_dev.php/login
, form shows up, can fill it, when submit it, got following error :
no route found "get /" (from "http://dev-05/antoine/symfony/web/app_dev.php/login") 404 not found - notfoundhttpexception 1 linked exception: resourcenotfoundexception »
after getting error, if go on home page, can see connected, it's working, redirection not .
according documentation, comes routing might wrongly configured, don't know made mistake.
here's form, security.yml , routing.yml files :
{% extends "akmuserbundle::layout.html.twig" %} {% block akmuser_body %} {% if error %} <div class="alert alert-danger">{{ error.message }}</div> {% endif %} <form action="{{ path('login_check') }}" method="post"> <label for="username">login : </label> <input type="text" id="username" name="_username" value="{{ last_username }}" /> <label for="password">mot de passe :</label> <input type="password" id="password" name="_password" /> <br /> <input type="submit" value="connexion" /> </form> {% endblock %}
security.yml :
security: encoders: symfony\component\security\core\user\user: plaintext role_hierarchy: role_admin: role_user role_super_admin: [role_user, role_admin, role_allowed_to_switch] providers: in_memory: memory: users: user: { password: userpass, roles: ['role_user'] } admin: { password: adminpass, roles: ['role_admin'] } firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: pattern: ^/ anonymous: true form_login: login_path: login check_path: login_check logout: path: logout target: /platform
routing.yml :
akm_platform: resource: "@akmplatformbundle/resources/config/routing.yml" prefix: /platform login: path: /login defaults: _controller: akmuserbundle:security:login login_check: path: /login_check logout: path: /logout
i'm aware .yml
files sensitive , need 4 spaces instead of usual indentation, rewrote files line line, spaces, still not working.
i hope can me :p if need informations don't hesitate!
edit : here result of php bin/console debug:router
edit 2 : rid of problem had add default_target_path in security.yml :
security: encoders: symfony\component\security\core\user\user: plaintext role_hierarchy: role_admin: role_user role_super_admin: [role_user, role_admin, role_allowed_to_switch] providers: in_memory: memory: users: user: { password: userpass, roles: ['role_user'] } admin: { password: adminpass, roles: ['role_admin'] } firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: pattern: ^/ anonymous: true form_login: login_path: login check_path: login_check default_target_path: akm_platform_home logout: path: logout target: /platform
refresh cache, console command:php bin/console cache:clear
, if using older symfony it's app/console instead of bin/console. can debug routes command: php bin/console debug:router
. main system console , in case use on windows. must in project folder them work.
i not sure redirected "/", started working in symfony , issues refreshing cache , wrong yml , route names. in case may symfony goes route / on successful login, can add default_target_path: your_homepage_route_name or /where_you_want_to_go
may what's issue here.
since you're new, when include routes , define prefix them, can forget set it, why router debugging great since can see info there easily. when working in symfony have console window open if not working in edior built in console. think jetbeans has it, of tutorials done in it. ps, youtube tutorials symfony great, example symfony , php programming channel has beginner tutorial.
Comments
Post a Comment