- Introduces the Symfony 2 DI container in a Symfony 1 application.
- Transforms a Symfony 2 doctrine configuration into a format readable for Symfony 1.x. Use Doctrine entities and propel classes with the same database configuration!
- Download Composer.
- Add to your composer.json
"require": {
"hostnet/hn-dependency-injection-plugin": "1.0.*"
}
- Run
php composer.phar install
. - Make
apps/<app>/config/<app>Configuration
extendHostnet\HnDependencyInjectionPlugin\ApplicationConfiguration
. - [Optional] override the
getKernel
method to return your own kernel, registering the bundles you want.protected function createKernel() { return new MyKernel($this); }
class MyKernel extends Hostnet\HnDependencyInjectionPlugin\Symfony1Kernel { public function registerBundles() { $bundles = array( new Symfony\Bundle\FrameworkBundle\FrameworkBundle() ); return array_merge($bundles, parent::registerBundles()); } }
- Create
apps/<app>/config/config.yml
to configure your Doctrine dbal, Doctrine orm, and possibly the FrameworkBundle. See also the example configuration. - If you don't want to generate the propel backwards compatability layer, add this
to
parameters: hn_entities_enable_backwards_compatible_connections: false
config.yml
, orparameters.yml
if you prefer to have them separate. - To ensure proper autoloading when using Doctrine entities, remove if you have
and add the following to your
require_once __DIR__ . '/../vendor/autoload.php';
config/ProjectConfiguration.php
.That way Doctrine knows where to find your entities.use Doctrine\Common\Annotations\AnnotationRegistry; $loader = require __DIR__.'/../vendor/autoload.php'; AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
- Be sure to set up your permissions properly, see "Setting up your permissions".
- After this is done we can do a little cleanup. To prevent confusion you should remove
config/databases.yml
, since only the Symfony 2 configuration is read at this point.
2.0.0
- Removed the Symfony1Panel class, it's added automatically now.
1.1.0
- Added a web debug panel with a link to the Symfony 2 profiler.
For this you need to activate the WebProfilerBundle, which you should only activate in dev
if ($this->getEnvironment() == 'dev') {
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
}
Then you need to configure the WebProfilerBundle and the profiler; add this to your config_dev.yml:
web_profiler:
toolbar: true
framework:
router: { resource: "%kernel.root_dir%/../config/sf2_routing_dev.yml" }
profiler:
only_exceptions: false
only_master_requests: true
Add this to sf2_routing_dev.yml
to make the WebProfilerBundle accessible:
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_main:
resource: sf2_routing.yml
And in web/*.php, replace $configuration->handle($request)->send();
with:
$response = $configuration->handle($request);
$response->send();
$configuration->terminate($request, $response);
You should now have a new panel in the Symfony 1 web debug toolbar with a link to the Symfony 2 profiler!
1.0.0
- First official release
0.15
- Added
hn_entities_enable_backwards_compatible_connections
parameter
- Clone the repository yourself
- Go to the directory of the clone
- Run
composer.phar install
- Run
phpunit