PHPackages                             aspendigital/fuel-doctrine2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. aspendigital/fuel-doctrine2

ActiveLibrary[Framework](/categories/framework)

aspendigital/fuel-doctrine2
===========================

Doctrine2 integration with FuelPHP

1.0.2(13y ago)1211.9k↑103.1%11LGPL-2.1+PHP

Since Jan 31Pushed 13y ago6 watchersCompare

[ Source](https://github.com/aspendigital/fuel-doctrine2)[ Packagist](https://packagist.org/packages/aspendigital/fuel-doctrine2)[ RSS](/packages/aspendigital-fuel-doctrine2/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (4)Used By (1)

FuelPHP Doctrine 2 Package
==========================

[](#fuelphp-doctrine-2-package)

About
-----

[](#about)

This package contains a basic wrapper around the Doctrine 2 ORM functionality for access using the FuelPHP framework. It is distributed under the same LGPL license as Doctrine itself.

How to install
--------------

[](#how-to-install)

You can install this package with Composer. So first you'll need Composer, which can be found at

1. If your application doesn't have a `composer.json` file please create it.
2. Add an additional `require`

```
"aspendigital/fuel-doctrine2": "dev-master"

```

3. Install with `composer install`

Quick start
-----------

[](#quick-start)

Configuration is simple and involves adding additional Doctrine configuration options to your FuelPHP db.php config.

To get running quickly, there are only three required settings:

in `app/config/db.php` add

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

and of course configure database settings (user, password etc) as you would normally do for Fuel.

How to use
----------

[](#how-to-use)

when you've configured your application, to get an EntityManager, use the following code:

```
$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
```

Or you can check the versions of the Doctrine components:

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

Typical configuration example
-----------------------------

[](#typical-configuration-example)

Using the cascading configuration files that FuelPHP offers, a typical configuration looks something like:

`app/config/db.php`:

```
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
	)
);
```

`app/config/development/db.php`:

```
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
	)
);
```

`app/config/production/db.php`:

```
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
	)
);
```

In the development environment, we use the default array cache (nothing is saved permanently) and enable profiling. In the production environment, we leave profiling off and use APC (or some other caching solution).

### Connection setting override

[](#connection-setting-override)

If for some reason you need to override Doctrine2 settings on a connection-by-connection basis, include a `doctrine2` key in your connection settings:

```
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
		)
	)
);
```

### Configuration options

[](#configuration-options)

Refer to the [Doctrine 2](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html) documentation

- `proxy_dir`: the directory containing your proxy classes
- `proxy_namespace`: the namespace where the proxy classes reside
- `metadata_path`: the directory containing your metadata
- `metadata_driver`: options are 'annotation' (default), 'php', 'simplified\_xml', 'simplified\_yaml', 'xml', 'yaml'
- `auto_generate_proxy_classes`: true/false for whether Doctrine should generate proxy classes for entities it loads
- `cache_driver`: options are 'array' (default), 'apc', 'xcache', 'wincache', 'zend'
- `init_callback`: A 'callable' value which will be run when the EntityManager is instantiated. This can be used to set up custom DBAL types or otherwise customize the environment.

`app/classes/myclass.php`:

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

On connection:

- `driver`: we try to guess the DBAL driver to load to connect to your database, but you may have to set this if the guessing doesn't work for you
- Consult the [Doctrine DBAL](https://github.com/doctrine/dbal/blob/master/docs/en/reference/configuration.rst) documentation for other DBAL-specific options

For FuelPHP options, refer to [Fuel database configuration](http://fuelphp.com/docs/classes/database/introduction.html)

- `type`
- `charset`
- `profiling`
- `enable_cache`: in our case, there is always some caching taking place, but it's only temporary unless you've changed the `cache_driver` setting
- `connection.persistent`
- `connection.compress`

Profiling
---------

[](#profiling)

No configuration is required beyond enabling profiling for your connection. Queries sent through Doctrine ORM and directly through DBAL will automatically appear in the Fuel profiler.

Doctrine 2 ORM
==============

[](#doctrine-2-orm)

Doctrine 2 is an object-relational mapper (ORM) for PHP 5.3.2+ that provides transparent persistence for PHP objects. It sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication.

More resources:
---------------

[](#more-resources)

- [Website](http://www.doctrine-project.org)
- [Documentation](http://www.doctrine-project.org/projects/orm/2.0/docs/reference/introduction/en)
- [Issue Tracker](http://www.doctrine-project.org/jira/browse/DDC)
- [Downloads](http://github.com/doctrine/doctrine2/downloads)

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 73.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~76 days

Total

3

Last Release

4750d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/520306d0cfae0a55106325622aaf3b44b9d0dc50b13b7baf2473e007df127880?d=identicon)[jimcottrell](/maintainers/jimcottrell)

---

Top Contributors

[![jimcottrell](https://avatars.githubusercontent.com/u/1483197?v=4)](https://github.com/jimcottrell "jimcottrell (14 commits)")[![davispuh](https://avatars.githubusercontent.com/u/651800?v=4)](https://github.com/davispuh "davispuh (5 commits)")

### Embed Badge

![Health badge](/badges/aspendigital-fuel-doctrine2/health.svg)

```
[![Health](https://phpackages.com/badges/aspendigital-fuel-doctrine2/health.svg)](https://phpackages.com/packages/aspendigital-fuel-doctrine2)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M387](/packages/easycorp-easyadmin-bundle)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M204](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k17.8k](/packages/prestashop-prestashop)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
