2013-04-26 36 views
13

Kể từ khi cập nhật lên symfony 2.2, thanh công cụ gỡ lỗi web không còn được tải trong app_dev.php nữa.Symfony 2 - Đã xảy ra lỗi khi tải thanh công cụ gỡ lỗi web (404: Not Found)

tôi nhận được lỗi sau:

An error occurred while loading the web debug toolbar (404: Not Found). 
Do you want to open the profiler? 

Trong prod.log tôi nhận được như sau:

request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /_profiler/84fb75cc3ffd5435474ebe4250e01fac2cdf49c1"" at /httpdocs/project/app/cache/prod/classes.php line 3597 [] [] 

request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /_wdt/452d5b4aa2dd9388285fa1c286d5c54218029c71"" at /httpdocs/priject/app/cache/prod/classes.php line 3597 [] [] 

Tôi đã xóa bộ nhớ cache nhiều lần :)

Thú vị là thực tế là trong /app_dev.php tất cả các liên kết trên trang không còn liên kết đến /app_dev.php nữa.

bao gồm cấu hình (/ _profiler/5fdc27cb82c4e9e426b3ab27377deb0b760fdca2) khi tôi sửa đổi url theo cách thủ công và thêm app_dev.php vào url, trình tải hồ sơ tải chính xác.

routing_dev.yml:

_assetic: 
    resource: . 
    type:  assetic 

_wdt: 
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" 
    prefix: /_wdt 

_profiler: 
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" 
    prefix: /_profiler 

_configurator: 
    resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml" 
    prefix: /_configurator 

_main: 
    resource: routing.yml 

tôi sẽ biết ơn sự giúp đỡ nào.

CẬP NHẬT I: config_dev.yml

imports: 
    - { resource: config.yml } 

framework: 
    router: { resource: "%kernel.root_dir%/config/routing_dev.yml" } 
    profiler: { only_exceptions: false } 

web_profiler: 
    toolbar: true 
    intercept_redirects: false 

monolog: 
    handlers: 
     main: 
      type: stream 
      path: %kernel.logs_dir%/%kernel.environment%.log 
      level: debug 
     firephp: 
      type: firephp 
      level: info 
     chromephp: 
      type: chromephp 
      level: info 

assetic: 
    use_controller: true 

CẬP NHẬT II: AppKernel.php

use Symfony\Component\HttpKernel\Kernel; 
use Symfony\Component\Config\Loader\LoaderInterface; 

class AppKernel extends Kernel 
{ 
    public function registerBundles() 
    { 
     $bundles = array(
      new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), 
      new Symfony\Bundle\SecurityBundle\SecurityBundle(), 
      new Symfony\Bundle\TwigBundle\TwigBundle(), 
      new Symfony\Bundle\MonologBundle\MonologBundle(), 
      new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), 
      new Symfony\Bundle\AsseticBundle\AsseticBundle(), 
      new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), 
      new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), 
      new JMS\AopBundle\JMSAopBundle(), 
      new JMS\DiExtraBundle\JMSDiExtraBundle($this), 
      new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(), 
      new myProject\MyBundle\myBundle(), 
      new FOS\UserBundle\FOSUserBundle(), 
      new myProject\MyBackendBundle\myBackendBundle(), 
     ); 

     if (in_array($this->getEnvironment(), array('dev', 'test'))) { 
      $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 
      $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); 
      $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); 
     } 

     return $bundles; 
    } 

    public function registerContainerConfiguration(LoaderInterface $loader) 
    { 
     $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); 
    } 
} 

Cập nhật III: .htaccess

DirectoryIndex app.php 

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L] 

    RewriteCond %{REQUEST_FILENAME} -f 
    RewriteRule .? - [L] 

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$ 
    RewriteRule ^(.*) - [E=BASE:%1] 
    RewriteRule .? %{ENV:BASE}app.php [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
    <IfModule mod_alias.c> 
     RedirectMatch 302 ^/$ /app.php/ 
    </IfModule> 
</IfModule> 

UPDATE: Tôi đã tìm thấy lỗi, đó là thẻ kết xuất sai (cũ) trong mẫu. :(

Cám ơn sự ủng hộ của bạn

+0

bạn có thể dán nội dung của config_dev của bạn? – NoScope

+0

bạn cũng có thể thêm tệp AppKernel.php của mình không? –

+0

Bạn có thể đăng bài .htaccess bằng RewriteRules của mình không? –

Trả lời

0

viết lại quy tắc của bạn có lẽ gây ra nó. Chỉ cần vài phút trước, tôi đã viết lại tôi và tôi đã có cùng một vấn đề với các hồ sơ.

+0

Với tệp .htaccess trống hoặc cũ hơn, sự cố vẫn tồn tại. – Bol

+0

Có thể có điều gì đó không ổn định ở bất cứ nơi nào trong lõi. Nếu không ai có thể cung cấp giải pháp. Có lẽ bạn nên thử cài đặt mới symfony 2.2. Chỉ cần di chuyển các nhóm của bạn, cấu hình lại, tạo lược đồ. Nó sẽ không mất nhiều thời gian của bạn làm điều đó hơn là gỡ lỗi đó. – Teffi

11

Tôi có vấn đề này quá, cố gắng chú ý đến .htaccess của bạn và làm cho nó trông như thế này:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 
    RewriteRule ^(.*) - [E=BASE:%1] 
    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteRule ^app_dev.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially 
    RewriteCond %{REQUEST_FILENAME} -f 
    RewriteRule .? - [L] 
    RewriteRule .? %{ENV:BASE}/app_dev.php [L]  ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially 
</IfModule> 

<IfModule !mod_rewrite.c> 
    <IfModule mod_alias.c> 
     # When mod_rewrite is not available, we instruct a temporary redirect of 
     # the startpage to the front controller explicitly so that the website 
     # and the generated links can still be used. 
     RedirectMatch 302 ^/$ /app.php/ 
     # RedirectTemp cannot be used instead 
    </IfModule> 
</IfModule> 
+0

cám ơn bạn đời! –

1

Một nguồn của lỗi này:.! cập nhật các máy chủ web Apache mà không uncommenting module rewrite tìm hiểu bằng cách làm

-6

chỉ cần khởi động lại vào WAMP/LAMP của bạn, nó làm việc cho tôi.

2

Tôi gặp sự cố này sau khi cài đặt ứng dụng của mình trên một hộp Linux mới. Tôi vừa quên kích hoạt mod_rewrite trong Apache2

[sudo] a2enmod rewrite 
[sudo] service apache2 restart 

Hy vọng nó sẽ hữu ích!

1

Tôi đã gặp lỗi này khi tôi sửa đổi mã nhà cung cấp cho mục đích gỡ lỗi. (Tôi biết nó không phải là cách đúng nhưng dù sao .. Tôi đã sửa đổi, thử nghiệm các ứng dụng web và quên quay trở lại mã nhà cung cấp).

Nếu trường hợp của bạn và bạn không nhớ chính xác bạn đã thực hiện các thay đổi "bất hợp pháp" đối với mã nhà cung cấp, bạn có thể xóa thư mục nhà cung cấp hoặc thành phần của nó và chạy lệnh php composer.phar update để kéo phiên bản gốc.

0

Với tôi điều này xảy ra khi tôi thay đổi .htaccess (từ thư mục web) để gọi app_dev.php thay vì app.php, nhưng tôi không thay đổi nó ở mọi nơi trong tệp .htaccess. Sau khi thay đổi tất cả các lần xuất hiện lỗi app_dev.php biến mất.

2

Trong Symfony 4 + Flex tôi đã phải cài đặt symfony/apache-pack recipie

composer req apache-pack 
+0

bạn đang sử dụng phiên bản symfony nào? –

+0

Symfony 4.0.1, Symfony Flex 1.0.48 – arexD