symfony-fosuserbundle 删除 hwi-oauthbundle 后未找到"GET /login/"的路由



我搜索了许多stackoverflow页面,并更新了源代码来解决这个问题。但我无法解决这个问题。想想我的代码中遗漏了什么,或者我更改了什么。

当我尝试访问"/login"时。它自动重定向到"/login/">

事实上,我的网站已经安装了三个捆绑包。

  • FosUserBundle
  • EsayAdminBundle
  • HWI捆绑包(稍后删除)

删除HWI oauth捆绑包后,它记录了此错误

未找到"GET/login/"的路由(来自http://127.0.0.1:8000/")

这是我在Symfony的第一个项目。任何人都可以给我你的更正和建议。我已经提到

Config.yml

imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "@BlogBundle/Resources/config/services.yml" }
- { resource: "@UserBundle/Resources/config/services.yml" }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: fr
framework:
#Annotation enabled here 
#validation: { enabled: true, enable_annotations: true }
#esi:             ~
translator:      { fallbacks: ["%locale%"] }
secret:          "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form:            ~
csrf_protection: ~
validation:      { enable_annotations: true }
#serializer:      { enable_annotations: true }
templating:
engines: ['twig']
default_locale:  "%locale%"
trusted_hosts:   ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id:  session.handler.native_file
save_path:   "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments:       ~
http_method_override: true
assets: ~
php_errors:
log: true
# Twig Configuration
twig:
debug:            "%kernel.debug%"
strict_variables: "%kernel.debug%"
cache : false    
# Doctrine Configuration
doctrine:
dbal:
driver:   pdo_mysql
host:     "%database_host%"
port:     "%database_port%"
dbname:   "%database_name%"
user:     "%database_user%"
password: "%database_password%"
charset:  UTF8
# if using pdo_sqlite as your database driver:
#   1. add the path in parameters.yml
#     e.g. database_path: "%kernel.root_dir%/../var/data/data.sqlite"
#   2. Uncomment database_path in parameters.yml.dist
#   3. Uncomment next line:
#path:     "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host:      "%mailer_host%"
username:  "%mailer_user%"
password:  "%mailer_password%"
spool:     { type: memory }

# app/config/config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
# other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: UserBundleEntityUser
from_email:
address: "test@myblog.org"
sender_name: "My-first-blog"

registration:
form:
type: UserBundleFormRegistrationType

easy_admin:
site_name: '<i class="fa fa-th" aria-hidden="true"></i> Hexagone - Espace Admin'
entities:
User: 
label : Utilisateurs
class : UserBundleEntityUser
list:
fields: ['username', 'email', 'enabled', 'last_login', 'roles','code_postal']
Projet :
class: BlogBundleProjetBundleEntityprojet
label : Projets
design:
brand_color: '#333333'

routing.yml

projet:
resource: "@ProjetBundle/Resources/config/routing.yml"
prefix:   /
blog_bundle_user:
resource: "@UserBundle/Resources/config/routing.yml"
prefix:   / 
blog:
resource: "@BlogBundle/Resources/config/routing.yml"
prefix:   /
app:
resource: "@AppBundle/Controller/"
type:     annotation
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
easy_admin_bundle:
resource: "@EasyAdminBundle/Controller/AdminController.php"
type:     annotation
prefix:   /backoffice

security.yml

security:
encoders:
FOSUserBundleModelUserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN:       ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
login_path: /login
check_path: /login_check
default_target_path:            /profile
# if you are using Symfony < 2.8, use the following config instead:
# csrf_provider: form.csrf_provider
logout:       true
anonymous:    true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
- { path: ^/backoffice, role: ROLE_ADMIN }

services.yml

服务:app.form.registration:类:UserBundle\Form\RegistrationType标记:-{name:form.type,别名:app_user_registration}

所有路由

_wdt                                ANY        ANY      ANY    /_wdt/{token}
_profiler_home                      ANY        ANY      ANY    /_profiler/
_profiler_search                    ANY        ANY      ANY    /_profiler/search
_profiler_search_bar                ANY        ANY      ANY    /_profiler/search_bar
_profiler_info                      ANY        ANY      ANY    /_profiler/info/{about}
_profiler_phpinfo                   ANY        ANY      ANY    /_profiler/phpinfo
_profiler_search_results            ANY        ANY      ANY    /_profiler/{token}/search/results
_profiler_open_file                 ANY        ANY      ANY    /_profiler/open
_profiler                           ANY        ANY      ANY    /_profiler/{token}
_profiler_router                    ANY        ANY      ANY    /_profiler/{token}/router
_profiler_exception                 ANY        ANY      ANY    /_profiler/{token}/exception
_profiler_exception_css             ANY        ANY      ANY    /_profiler/{token}/exception.css
_twig_error_test                    ANY        ANY      ANY    /_error/{code}.{_format}
projet_homepage                     ANY        ANY      ANY    /projet
blog_bundle_user_homepage           ANY        ANY      ANY    /
blog_homepage                       ANY        ANY      ANY    /
githut                              ANY        ANY      ANY    /
homepage                            ANY        ANY      ANY    /
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_profile_show               GET        ANY      ANY    /profile/
fos_user_profile_edit               GET|POST   ANY      ANY    /profile/edit
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
fos_user_resetting_request          GET        ANY      ANY    /resetting/request
fos_user_resetting_send_email       POST       ANY      ANY    /resetting/send-email
fos_user_resetting_check_email      GET        ANY      ANY    /resetting/check-email
fos_user_resetting_reset            GET|POST   ANY      ANY    /resetting/reset/{token}
fos_user_change_password            GET|POST   ANY      ANY    /profile/change-password
easyadmin                           ANY        ANY      ANY    /backoffice/
admin                               ANY        ANY      ANY    /backoffice/

对不起,我粘贴代码时可能遗漏了缩进。还需要什么来解决这个问题?我可以粘贴在这里。

注意:我也试过我的旧版本,它不是hwi oauth捆绑包。它也遇到了同样的问题。

我再次浏览了fosbundle安装页面。我没有任何线索。

看起来您正在尝试访问应用程序中的路径/login/,但只有一个路由定义的fos_user_security_login具有路径/login(没有尾随的/)。

以这种方式CCD_ 5与CCD_ 6不匹配。您还需要定义第二条路由来匹配此路径。

相关内容

  • 没有找到相关文章

最新更新