我創建了名爲「test」的路線,但symfony無法找到它。symfony 2找不到我創建的路線
Routing_dev.php
_test:
resource: "@AcmetestBundle/Controller/testController.php"
type: annotation
pattern: /test
添加這一行AppKernel.php
$bundles[] = new Acme\testBundle\AcmetestBundle();
創建後述的目錄
- Acme公司| 1.1 testBundle | 1.11 AcmetestBundle.php | 1.12控制器 | 1.13 testController.php
AcmetestBundle.php
namespace Acme\testBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AcmetestBundle extends Bundle
{
public function __construct(){
var_dump("initializing ".__DIR__);
}
}
testController.php
namespace Acme\testBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Acme\DemoBundle\Form\ContactType;
// these import the "@Route" and "@Template" annotations
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class testController extends Controller
{
/**
* @Route("/", name="_demo")
* @Template()
*/
public function indexAction()
{ var_dump(11);
return array("");
}
}
瀏覽器記錄:
沒有找到與 「GET /測試」 404未航線找到 - NotFoundHttpException 1鏈接例外:重新sourceNotFoundException»
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException:在C:\ xampp \ htdocs \ Symfony \ app \ cache \ dev \ classes.php行中找到「GET/test」(未捕獲的異常)線路4560行
是什麼'PHP應用程序/控制檯路線:dump'說? – meze 2012-02-19 09:16:08