2015-04-06 65 views
-1

最後更新:Symfony2中沒有路由的工作

這改變混亂的Drupal太讓我重新安裝了XAMPP,我不ATM有這個問題,我認爲主題被關閉。

更新:

奇怪我處理了頁面上顯示的錯誤。我擺脫了這一行::throw 0 < count($ allow)?新的MethodNotAllowedException(array_unique($ allow)):new ResourceNotFoundException(); [1/2] ResourceNotFoundException:

和它似乎工作

但是當我在classes.php刪除線2117(該ELSEIF所以3行

elseif (is_object($controller)) { 
    $repr = get_class($controller); 
    } 

) 在/ opt/LAMPP /htdocs/Symfony/app/cache/dev/classes.php我得到一個新的錯誤,甚至當我把ELSEIF回來...

這裏的消息:

箍,看上去像是出了問題。 1/1 FatalErrorException在classes.php線2117:解析錯誤:語法錯誤,意外 'ELSEIF'(T_ELSEIF)

在classes.php線

我從明天開始在Symfony2的工作對於我的第一次專業經驗,但奇怪的是,這次我有問題使它在我的燈/ Kubuntu上工作。

這是我嘗試:

下載:Symfony_Standard_Vendors_2.6.4.zip(因此它在壓縮文件),這是kunbutu下載文件夾 MV的Symfony ../../../var/www

這些URL不起作用:

http://localhost/Symfony/web/app_dev.php/hello/winzou http://localhost/Symfony/web/app_dev.php/hello/World

兩個頁面錯誤(除了獲取/你好/ ..明顯的部分)顯示的是: 錯誤 - 未捕獲到PHP異常Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException:「找不到」GET/hello/winzou「路徑/opt/lampp/htdocs/Symfony/app/cache/dev/classes.php 2017

in app/cache/dev/classes.php at line 2017 - 

if ($referer = $request->headers->get('referer')) { 
$message .= sprintf(' (from "%s")', $referer); 
} 
throw new NotFoundHttpException($message, $e); 
} catch (MethodNotAllowedException $e) { 
$message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), implode(', ', $e->getAllowedMethods())); 
throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); 

at RouterListener ->onKernelRequest (object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher)) 
at call_user_func (array(object(RouterListener), 'onKernelRequest'), object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher)) 
in vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php at line 61 + 
at WrappedListener ->__invoke (object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher)) 
at call_user_func (object(WrappedListener), object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher)) 
in app/cache/dev/classes.php at line 1790 + 
at EventDispatcher ->doDispatch (array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(GetResponseEvent)) 
in app/cache/dev/classes.php at line 1723 + 
at EventDispatcher ->dispatch ('kernel.request', object(GetResponseEvent)) 
in app/cache/dev/classes.php at line 1884 + 
at ContainerAwareEventDispatcher ->dispatch ('kernel.request', object(GetResponseEvent)) 
in vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php at line 112 + 
at TraceableEventDispatcher ->dispatch ('kernel.request', object(GetResponseEvent)) 
in app/bootstrap.php.cache at line 3011 + 
at HttpKernel ->handleRaw (object(Request), '1') 
in app/bootstrap.php.cache at line 2984 + 
at HttpKernel ->handle (object(Request), '1', true) 
in app/bootstrap.php.cache at line 3133 + 
at ContainerAwareHttpKernel ->handle (object(Request), '1', true) 
in app/bootstrap.php.cache at line 2377 + 
at Kernel ->handle (object(Request)) 
in web/app_dev.php at line 28 + 

和:

[2/2] NotFoundHttpException:未找到路線 「GET /你好/世界」 +

if ($referer = $request->headers->get('referer')) { 
$message .= sprintf(' (from "%s")', $referer); 
} 
throw new NotFoundHttpException($message, $e); 
} catch (MethodNotAllowedException $e) { 
$message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), implode(', ', $e->getAllowedMethods())); 
throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); 


if ($referer = $request->headers->get('referer')) { 
$message .= sprintf(' (from "%s")', $referer); 
} 
throw new NotFoundHttpException($message, $e); 
} catch (MethodNotAllowedException $e) { 
$message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), implode(', ', $e->getAllowedMethods())); 
throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); 

[1/2] ResourceNotFoundException: -

in app/cache/dev/appDevUrlMatcher.php at line 244 - 
      } 
      throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); 
     } 
    } 

,它不漂亮,但這裏是整個頁面顯示:


Symfony的 上Symfony的網站搜索 異常檢測! 找到的 「GET /你好/世界」 否路線 404未找到 - NotFoundHttpException 1連接異常:

ResourceNotFoundException » 

[2/2] NotFoundHttpException:未發現 「GET /你好/世界」 + 路線[1/2] ResourceNotFoundException:+ 原木 - 1錯誤

ERROR - Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /hello/World"" at /opt/lampp/htdocs/Symfony/app/cache/dev/classes.php line 2017 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 
DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Acme\DemoBundle\EventListener\ControllerListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". 

堆棧跟蹤(純文本)+


所以我的猜測是要改變class.php的2017年線,但要放什麼?

我也嘗試在該文件夾的Symfony通過教程的建議:

搭配chmod 777 -R應用程序/緩存 搭配chmod 777 -R應用/日誌

還是同樣的問題...


app/config/routes確實是空的,沒有路徑文件夾我應該放什麼?我如何看到dev和prod之間的區別?

儘量設置2,3和第3步中得到這個:

[路由器]當前路線 名稱方法方案主機路徑
_wdt ANY ANY ANY/_wdt/{令牌}
_profiler_home ANY ANY ANY/_profiler/
_profiler_search任何任何任何/ _profiler /搜索
_profiler_search_bar任何任何任何/ _profiler/search_bar
_profiler_purge任何任何任何/ _profiler /吹掃
_profiler_info任何任何任何/ _profiler /信息/ {有關}
_profiler_phpinfo ANY ANY ANY/_profiler /的phpinfo
_profiler_search_results ANY ANY ANY/_profiler/{令牌} /搜索/結果
_profiler ANY ANY ANY/_profiler/{令牌}
_profiler_router ANY ANY ANY/_profiler/{令牌} /路由器
_profiler_exception任何任何任何/ _profiler/{令牌} /異常
_profiler_exception_css任何任何任何/_profiler/{token}/exception.css
_configurator_home任何任何任何/ _configurator/
_configurator_step任何任何/ _configurator/step/{index}
_configurator_final任何任何/ _configurator/final
_twig_error_test任何任何/ _error/{code}。{_format}
主頁任何任何任何/應用/示例
_welcome任何任何任何/
_demo_login任何任何任何/演示/固定/登錄
_demo_security_check任何任何任何/演示/固定/ login_check
_demo_logout任何任何任何/演示/安全/註銷
acme_demo_secured_hello ANY ANY ANY /演示/安全/你好
_demo_secured_hello ANY ANY ANY /演示/安全/你好/ {名}
_demo_secured_hello_admin ANY ANY ANY /演示/安全/你好/管理/ {名稱}
_demo任何任何/ demo/
_demo_hello ANY ANY ANY /演示/你好/ {name}的
_demo_contact ANY ANY ANY /演示/接觸

UPDATE:

奇怪我處理頁面上顯示的錯誤。我擺脫了這一行::throw 0 < count($ allow)?新的MethodNotAllowedException(array_unique($ allow)):new ResourceNotFoundException(); [1/2] ResourceNotFoundException:

和它似乎工作

但是當我在/ opt/LAMPP/htdocs中/ Symfony的/應用程序/緩存中刪除在classes.php線2117(該ELSEIF這樣3條線) /dev/classes.php我得到一個新的錯誤,甚至當我把ELSEIF回來...


這裏的消息:

籃球,看起來像出事了。 1/1 FatalErrorException在classes.php線2117:解析錯誤:語法錯誤,意外 'ELSEIF'(T_ELSEIF)

in classes.php line 2117 

因爲我只有在無功/網絡開始安裝,而不是選擇/ I」無言以對,歡迎任何幫助!

+0

你如何註冊這些路線?任何代碼? – 2015-04-06 12:08:51

+0

哪些文件需要去給你的代碼?我默認做了所有事情,「hello」是一個安裝在symfony2 – user3595784 2015-04-06 12:10:56

回答

0
  1. 檢查你的應用程序/配置/路由(開發和底座)
  2. 在主文件夾中運行命令app/console cache:clear測試,如果它的工作
  3. 在主文件夾中運行命令app/console route:debug視圖如果沒有列出您的路線
+0

中的默認控制器。奇怪的是,我處理了頁面上顯示的錯誤。我擺脫了這一行:[1/2] ResourceNotFoundException: - – user3595784 2015-04-06 13:36:13

+0

cd到/ www/Symfony並在它內部嘗試:php app/console cache:clear !!!所有的應用/緩存文件都是臨時的,所以你不能修復它們,因爲它們在某個時候會被刪除 – Svetoslav 2015-04-06 14:05:46