Symfony2: what Symfony git repository can I use to start a project?
Can you give me some information on how to create a new Symfony2 project?
I started to get the symfony/symfony-sandbox from github as a tar-ball. Then I removed its old src/vendor content.
I get latest vendor libs with git submodule. ( fabpot/Symfony, doctrine, migrations, ...).
The problem is the sandbox seems out of date compared to latest fabpot/Symfony code.
So I started to modify what changed ( F开发者_StackOverflow社区oundationBundle rename, some method signature changes (like registerContainerConfiguration, ... ).
I still get this error:
Symfony\Components\HttpKernel\Exception\NotFoundHttpException: Unable to find the controller.
It seems to be a problem with routing: the request matches no controller.
Do you have any idea?
Even better, does anybody has a sandbox which works with latest Symfony code?
The main problem is that Symfony changes too fast to maintain a working solution based on the trunk/main branch.
Maybe I had not the best approach on how to start, but after some searchs, I came to a solution:
I finally found my problem:
all my problems were DI related.
The first problem was that the ControllerLoaderListener wasn't observing the "core.load_controller" event.
It was because I had deactivated the web extension in my config.yml ( shame on me... but I was testing!)
After that, I had another problem with the "router" service. It wasn't loaded neither!
By looking here:
src/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/application/yml/config/config.yml
I found that the router service is activated by this config.yml:
parameters:
kernel.include_core_classes: false
kernel.config: ~
web.config: #enables the Web DI extension
router: { resource: "%kernel.root_dir%/config/routing.yml" } #enables the Routing DI extension
web.templating: ~
doctrine.dbal: ~
doctrine.orm: ~
If I say this to you all, It's just because I hope to economize some headaches to other people :)
And if someone's interested, here is a working Kernel who works with latest fabpot/Symfony repo.
<?php
require_once __DIR__.'/../src/autoload.php';
use Symfony\Framework\Kernel;
use Symfony\Components\Routing\Loader\YamlFileLoader as RoutingLoader;
use Symfony\Components\DependencyInjection\Loader\LoaderInterface;
class ECommerceKernel extends Kernel
{
public function registerRootDir()
{
return __DIR__;
}
public function registerBundles()
{
$bundles = array(
new Symfony\Framework\KernelBundle,
new Symfony\Bundle\FrameworkBundle\FrameworkBundle,
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle,
new Symfony\Bundle\DoctrineBundle\DoctrineBundle,
new Symfony\Bundle\DoctrineMigrationsBundle\DoctrineMigrationsBundle,
new Application\ECommerceBundle\ECommerceBundle,
);
if ($this->isDebug()) {
}
return $bundles;
}
public function registerBundleDirs()
{
$bundles = array(
'Application' => __DIR__.'/../src/Application',
'Bundle' => __DIR__.'/../src/Bundle',
'Symfony\\Framework' => __DIR__.'/../src/vendor/symfony/src/Symfony/Framework',
'Symfony\\Bundle' => __DIR__.'/../src/vendor/symfony/src/Symfony/Bundle',
);
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
return $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
public function registerRoutes()
{
$loader = new RoutingLoader($this->getBundleDirs());
return $loader->load(__DIR__.'/config/routing.yml');
}
}
精彩评论