PHP code example of aspendigital / fuel-doctrine2

1. Go to this page and download the library: Download aspendigital/fuel-doctrine2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aspendigital / fuel-doctrine2 example snippets


'doctrine2'=>array(
	'proxy_dir' => APPPATH . 'classes' . DS . 'proxy',
	'proxy_namespace' => 'Proxy',
	'metadata_path' => APPPATH . 'classes' . DS . 'entity'
)

$em = \Fuel\Doctrine::manager(); // Uses the connection referred to by the 'active' index in your configuration
$em = \Fuel\Doctrine::manager('connection_2'); // Specify connection explicitly

print_r(\Fuel\Doctrine::version_check());

return array(
	'active'=>'default',

	'doctrine2'=>array(
		'proxy_dir'       => APPPATH . 'classes' . DS . 'proxy',
		'proxy_namespace' => 'Proxy',
		'metadata_path'   => APPPATH . 'classes' . DS . 'entity',
		'metadata_driver' => 'annotation',
		'init_callback'   => array('MyClass', 'init')
	)

	/**
	 * Base config, just need to set the DSN, username and password in env. config.
	 */
	'default' => array(
		'type'        => 'pdo',
		'connection'  => array(
			'persistent' => false,
			'compress'   => false
		),
		'charset'      => 'utf8',
		'profiling'    => false
	)
);

return array(
	'doctrine2'=>array(
		'auto_generate_proxy_classes' => true
	),

	'default'=>array(
		'connection'  => array(
			'dsn'            => 'pgsql:host=localhost;dbname=fuel_db',
            'username'       => 'your_username',
            'password'       => 'y0uR_p@ssW0rd'
		)
		'profiling'   => true
	)
);

return array(
	'doctrine2'=>array(
		'auto_generate_proxy_classes'   => false,
		'cache_driver'                  => 'apc'
	),

	'default'=>array(
		'connection'  => array(
			'dsn'            => 'pgsql:host=production_server;dbname=fuel_db',
            'username'       => 'your_username',
            'password'       => 'y0uR_p@ssW0rd'
		)
		'profiling'    => false
	)
);

return array(

	'default'=>array(
		'connection'  => array(
			'dsn'            => 'pgsql:host=production_server;dbname=fuel_db',
            'username'       => 'your_username',
            'password'       => 'y0uR_p@ssW0rd'
		)
		'profiling'    => false,
		'doctrine2'    => array(
			'cache_driver'   => 'zend' // Override the cache driver only for the 'default' connection
		)
	)
);

class MyClass
{
	/**
	 * @param \Doctrine\ORM\EntityManager $manager
	 * @param string $connection
	 */
	public static function init($manager, $connection)
	{
		...
	}
}