2016-11-11 62 views
2

我試圖創建的symfony了新的一頁,無法重新路由在頁面的symfony

// src/AppBundle/Controller/LuckyController.php 
namespace AppBundle\Controller; 

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 
use Symfony\Component\HttpFoundation\Response; 

class LuckyController 
{ 
    /** 
    * @Route("/luckynumber") 
    */ 
    public function numberAction() 
    { 
     $number = mt_rand(0, 100); 

     return new Response(
      '<html><body>Lucky number: '.$number.'</body></html>' 
     ); 
    } 
} 

路由設置這樣

app: 
resource: "@AppBundle/Controller/" 
type:  annotation 

,我試圖訪問它在這個網址https://proj/proj/web/luckynumber。它只是返回404錯誤..我的項目是在https://proj/proj文件夾。

+0

:'PHP應用程序/控制檯調試:router'? (對於symfony3是:'php bin/console debug:router')。你看到那條路線嗎? –

+0

是的,有'name:app_lucky_number路徑:/ luckynumber'的行。 – rtom

+1

好吧。現在您可以手動清除應用程序緩存(刪除env緩存文件夾)或使用:'php app/console cache:clear --env = dev'並嘗試輸入正確的URL。如果你在當地工作,應該是:yourdomain.ltd/app_dev.php/luckynumber –

回答