我正在使用FOSUserBundle,我遇到了一个错误,我无法纠正。(我使用Symfony 3.2.9)
我想它来自我的security.yml文件,但我找不到是什么使我的路由错误。
这可能只是一个细节,但我使用nginx,我的本地url是: 127.0.0.1:83/app_dev.php/。
只有我的/login路线不起作用。
我的url是/login
**,,但它将我重定向到** /login/
我得到了:No route found for "GET /login/" (from "http://127.0.0.1:83/app_dev.php/")
这是我的security.yml文件:
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy: ~
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
logout: true
anonymous: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
我的config.yml (fosuserbundle配置):
# FOSUser Configuration
fos_user:
db_driver: orm
from_email:
address: my@email.fr
sender_name: Admin
firewall_name: main
user_class: ProjectBundle\Entity\User\User
registration:
form:
type: ProjectBundle\Form\RegistrationType
和php bin/console debug:router
:
admin_user_index ANY ANY ANY /admin/user/
admin_user_show ANY ANY ANY /admin/user/{id}/show
admin_user_edit ANY ANY ANY /admin/user/{id}/edit
admin_user_new ANY ANY ANY /admin/user/create
home ANY ANY ANY /
lexik_translation_overview GET ANY ANY /admin/translations/
lexik_translation_grid GET ANY ANY /admin/translations/grid
lexik_translation_new GET|POST ANY ANY /admin/translations/new
lexik_translation_invalidate_cache GET ANY ANY /admin/translations/invalidate-cache
lexik_translation_list GET ANY ANY /admin/translations/api/translations
lexik_translation_profiler GET ANY ANY /admin/translations/api/translations/profiler/{token}
lexik_translation_update PUT ANY ANY /admin/translations/api/translations/{id}
lexik_translation_delete_locale DELETE ANY ANY /admin/translations/api/translations/{id}/{locale}
lexik_translation_delete DELETE ANY ANY /admin/translations/api/translations/{id}
fos_user_security_login GET|POST ANY ANY /login
fos_user_security_check POST ANY ANY /login_check
fos_user_security_logout GET|POST ANY ANY /logout
fos_user_registration_register GET|POST ANY ANY /register/
fos_user_registration_check_email GET ANY ANY /register/check-email
fos_user_registration_confirm GET ANY ANY /register/confirm/{token}
fos_user_registration_confirmed GET ANY ANY /register/confirmed
编辑:更多信息
我的routing.yml:
project:
resource: "@ProjectBundle/Controller/"
type: annotation
prefix: /
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
登录路径的routing.xml:FOSUserBundle路由文件
也许我的问题来自于我的Nginx配置(这是我第一次使用它):
server {
listen 83 default_server;
listen [::]:83 default_server;
server_name localhost;
root /var/www/html/MyProject/web;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
try_files $uri /app.php$is_args$args;
}
location ~ ^/(app|app_dev|app_test|config)\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
有谁有主意吗?我真的被困在我的项目里了。提前谢谢你。
发布于 2017-05-31 14:59:22
塞弗尼布置得很好。我在当地重复一遍。同时也为apache2和nginx工作。我建议使用nginx配置文件。地点区看起来很可疑。
发布于 2017-05-31 11:05:51
No route found for "GET /login/"
表示路由不存在并且是正确的,如果您查看您的php bin/console debug:router
,您可以看到路由是/login
而不是/login/
,请删除最后一个斜杠。
https://stackoverflow.com/questions/44282729
复制相似问题