indigophp/fuel-doctrine

This package is abandoned and no longer maintained. No replacement package was suggested.

Fuel Doctrine 2 integration

dev-develop 2014-09-21 19:25 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:38:29 UTC


README

Build Status Latest Stable Version Total Downloads License Dependency Status

This package is a wrapper around doctrine/doctrine2 package.

Install

Via Composer

{
    "require": {
        "indigophp/fuel-doctrine": "@stable"
    }
}

Usage

$manager = \Doctrine\Manager::forge('default');

$em = $manager->getEntityManager();

Configuration

To make it work, you need the following doctrine configuration.

	'dbal'                        => 'default',
	'proxy_dir'                   => '/tmp',
	'proxy_namespace'             => 'PrOxYnAmEsPaCe',
	'auto_generate_proxy_classes' => true,
	'mappings'                    => array(
		'mapping' => array(
			'type'   => 'xml',
			'dir'    => '/mypath',
			'prefix' => 'MyPrefix',
		),
	),
	'cache_driver'                => 'array',

You can also use the Setup class to auto configure the Configuration object.

	'dbal'            => 'default',
	'auto_config'     => true,
	'dev_mode'        => \Fuel::$env === \Fuel::DEVELOPMENT,
	'proxy_dir'       => '/tmp',
	'cache_driver'    => 'array',

Multiple managers

By default you have one manager (default). If you would like use multiple managers, you have to add a key managers to your doctrine config, and set your configurations there. You can also set global configurations in the config root. Make sure to set auto_mapping to false.

	'auto_mapping'    => false,
	'dbal'            => 'default',
	'managers'        => array(
		'default'   => array(),
		'aditional' => array()
	),

Note: This package uses indigophp/fuel-dbal for connections. Check the package documentation.

Running doctrine commands

Doctrine comes with a CLI tool by default, however it is a bit hard use it the official way (cli-config.php in the project root folder). So I wrapped it in an oil command. It is working, but it is still just a hack ("oil" and "r" or "refine" are just removed from the argument list), so use it with caution.

Example:

oil r doctrine orm:schema-tool:drop --force
oil r doctrine orm:schema-tool:create

General syntax:

oil r doctrine [command]

If you want to use a specific Manager instance put a DB env var before the command:

DB=my_doctrine_instance oil r doctrine [command]

Note: Make sure the doctrine package is loaded in fuel otherwise the task will not work.

Testing

$ codecept run

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.