私はSymfonyを初めて利用しますが、PHPは使用しません。なぜ私はカスタムバンドルから作業するためのホームページルートを得ることができないのか分かりませんが、コンソール出力から動作しているようです。ウェブブラウザでルートを実行すると、AppBundleがAppKernal.php内のregisterBundles()
機能から削除されても、常にAppBundleからの/
ルート、つまりデフォルトのSymfonyウェルカムページが返されます。しかしカスタムバンドル経由のsymfonyルーティングは、コンソールモードでのみ動作します。
[2016-06-22 19:07:57] request.INFO: Matched route "homepage". {"route_parameters":{"_controller":"AppBundle\\Controller\\DefaultController::indexAction","_route":"homepage"},"request_uri":"http://bvd-v3.dev/"} []
[2016-06-22 19:07:57] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2016-06-22 19:07:57] request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "Class "AppBundle\Controller\DefaultController" does not exist." at /Users/apple/projects/mentel/bvd-v3/var/cache/prod/classes.php line 2498 {"exception":"[object] (InvalidArgumentException(code: 0): Class \"AppBundle\\Controller\\DefaultController\" does not exist. at /Users/apple/projects/mentel/bvd-v3/var/cache/prod/classes.php:2498)"} []
私はphp bin/console router:match /
を呼び出す場合出力され、::
+--------------+---------------------------------------------------------+
| Property | Value |
+--------------+---------------------------------------------------------+
| Route Name | homepage |
| Path |/ |
| Path Regex | #^/$#s |
| Host | ANY |
| Host Regex | |
| Scheme | ANY |
| Method | ANY |
| Requirements | NO CUSTOM |
| Class | Symfony\Component\Routing\Route |
| Defaults | _controller: MentelBundle:Index:index |
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
+--------------+---------------------------------------------------------+
場合/ SRCからAppBundleディレクトリを削除した場合、私は、次のエラーログを取得するので、私はこれを確認することができます私はphp bin/console debug:router
呼び出し出力は、次のとおりです。
routing.ymlの内容:routing_dev.ymlの
mentel:
resource: "@MentelBundle/Controller/"
type: annotation
内容:/app/AppKernal.phpでregisterBundles()
の
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_errors:
resource: "@TwigBundle/Resources/config/routing/errors.xml"
prefix: /_error
_main:
resource: routing.yml
内容:
public function registerBundles()
{
$bundles = [
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 Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new BVD\MentelBundle\MentelBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
コントローラの内容:
<?php
namespace BVD\MentelBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class IndexController extends Controller
{
/**
* @Route("/", name="homepage")
*/
public function indexAction()
{
die('?');
return $this->render('@mentel/pages/home.html.twig', array(
// ...
));
}
}
私の質問を読んでくれてありがとう、本当にあなたが提供できる任意のヘルプに感謝します。
ので、私はそこにあると誤解だと思います。あなたが使用する必要がある場合は、@ Route( "/"、name = "homepage")はhostname.de/ homtをルートとしていることを意味します。 – fucethebads
私は ' ''/homepage' ''/homepage' ''ルートを/ something_elseに変更するので、ドメインから提供されたルート、 '' http:// example.com' 'が '/'ですが、あなたの言うことは関係ありません。 'はSymfony 404を提供するだけです.AppBundleルートがないので、 – DrewT
キャッシュをクリアしようとしましたか( 'bin/console cache:clear')? – Oldskool