2017-06-22 339 views
0

我已經搜索了很多stackoverflow頁面並更新了我的源代碼來解決這個問題。但我無法解決這個問題。以爲我在代碼中遺漏了某些東西,或者我改變了一些東西。symfony-fosuserbundle刪除後找不到路由「GET/login /」hwi-oauthbundle

當我嘗試訪問「/登錄」。它會自動重定向到「/ login /」

其實我的網站已經安裝了三個軟件包。

  • FosUserBundle
  • EsayAdminBundle
  • HWI包(後來刪除)

去除HWI OAuth的包後,中遇到這個錯誤

沒有找到與「GET /登錄路由/「(來自」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: UserBundle\Entity\User 

    from_email: 
     address: "[email protected]" 
     sender_name: "My-first-blog" 


    registration: 
     form: 
      type: UserBundle\Form\RegistrationType 


easy_admin: 
    site_name: '<i class="fa fa-th" aria-hidden="true"></i> Hexagone - Espace Admin' 
    entities: 
     User: 
      label : Utilisateurs 
      class : UserBundle\Entity\User 
      list: 
       fields: ['username', 'email', 'enabled', 'last_login', 'roles','code_postal'] 

     Projet : 
      class: BlogBundle\ProjetBundle\Entity\projet 
      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: 
     FOS\UserBundle\Model\UserInterface: 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 \表格\ RegistrationType 標籤: - {名稱: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/ 

對不起,我可能錯過了,當我粘貼代碼。需要Whatelse來解決這個問題?我可以粘貼在這裏。

注意:我也試過我的舊版本,這不是hwi-oauth捆綁軟件。它出現了同樣的問題。

我已經通過fosbundle安裝頁面再次走了。我沒有任何線索。

回答

0

看起來您嘗試在您的應用程序中訪問路徑/login/,但只有一條路徑定義爲fos_user_security_login,路徑爲/login(沒有尾隨/)。

/login/這樣與RouteMatcher不匹配。您還需要定義第二條路線以匹配此路徑。

+0

我並非試圖訪問「/ login /」,當我嘗試訪問「/ login」時。它會自動重定向到「/ login /」 –

+0

我已經檢查了所有的備份。除了找不到的「/ login」之外,所有鏈接都能正常工作 –