Download the PHP package opensolutions/doctrine2bridge without Composer

On this page you can find all versions of the php package opensolutions/doctrine2bridge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package doctrine2bridge

Doctrine2Bridge

Adds the power of Doctrine2 to Laraval 4 (including authentication and SQL query logging support).

Laravel's Eloquent ORM is nice for lightweight use, however there's little out there that can beat Doctrine when you need a more full-featured ORM.

This is an integration of Doctrine 2.x to Laravel 4.x as a composer package. Doctrine's EntityManager instance is accessible through a facade named D2EM and the cache is directly available via D2Cache.

Metadata is currently obtained via the XML driver. It should be easy to add additional drivers to this.

Authentication support is also included via a Auth/Doctrine2UserProvider class. Documentation on integrating this with Laravel's own authentication system can be found here.

Installation

Installation is the usual for Laravel packages. You can find a detailed worked version of how to install and test in the wiki.

Insert the following in the packages (require) section of your composer.json file and run an update (composer update):

"opensolutions/doctrine2bridge": "2.4.*",

Generally speaking, we'll try and match our minor versions (2.4.x) with Doctrine's but you should always use the latest x version of this.

Note that your minimum stability must be dev for Doctrine migrations. If the above command complains, ensure you have the following set in your composer.json file:

"minimum-stability": "dev"

Add the service providers to your Laravel application in app/config/app.php. In the 'providers' array add:

'Doctrine2Bridge\Doctrine2CacheBridgeServiceProvider',
'Doctrine2Bridge\Doctrine2BridgeServiceProvider',

You'll need to public and edit the configuration file:

./artisan config:publish opensolutions/doctrine2bridge

This should get you a fresh copy of the configuration file in the directory app:

config/packages/vendor/opensolutions/doctrine2bridge

Documentation on integrating this with Laravel's own authentication system can be found here.

Usage

Two facades are provided - one for the Doctrine2 cache and the other for the entity manager. These can be used as follows:

D2Cache::save( $key, $value );
D2Cache::fetch( $key );

D2EM::persist( $object );
D2EM::flush();
$users = D2EM::getRepository( 'Entities\User' )->findAll();

More Detailed Usage

The configuration file by default expects to find XML schema definitions under doctrine/schema. Let's say for example we have a single schema file called doctrine/schema/Entities.SampleEntity.dcm.xml containing:

<?xml version="1.0"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity name="Entities\SampleEntity" repository-class="Repositories\Sample">
        <id name="id" type="integer">
            <generator strategy="AUTO"/>
        </id>
        <field name="name" type="string" length="255" nullable="true"/>
    </entity>
</doctrine-mapping>

Assuming you've configured your database connection parameters in the config file and you're positioning in the base directory of your project, we can create the entities, proxies and repositories with:

./vendor/bin/doctrine2 orm:generate-entities app/models/
./vendor/bin/doctrine2 orm:generate-proxies
./vendor/bin/doctrine2 orm:generate-repositories app/models/

You can also (drop) and create the database with:

./vendor/bin/doctrine2 orm:schema-tool:drop --force
./vendor/bin/doctrine2 orm:schema-tool:create

Now you can add some data to the database:

$se = new Entities\SampleEntity;
$se->setName( rand( 0, 100 ) );
D2EM::persist( $se );
D2EM::flush();

And query it:

echo count( D2EM::getRepository( 'Entities\SampleEntity' )->findAll() );

I use the excellent ORM Designer to create and manage my XML schema files.

Convenience Function for Repositories

If, like me, you spend a lot of time typing D2EM::getRepository( 'Entities\XXX' ), then add the following to the end of bootstrap/start.php:

include $app['path.base'] . '/vendor/opensolutions/doctrine2bridge/src/bootstrap/d2r.php';

and then you can replace the above with: D2R( 'XXX' ). I use Entities as my namespace generally so this function is just as follows (which you can easily change to suit yourself):

function D2R( $entity, $namespace = 'Entities' )
{
    return D2EM::getRepository( $namespace . '\\' . $entity );
}

SQL Query Logging

This package includes an implementation of Doctrine\DBAL\Logging\SQLLlogger which times the queries and calls the Laravel Log facade to log the query execution times and the SQL queries.

This logger can be enabled in the configuration file.

 License

Like the Laravel framework itself, this project is open-sourced under the MIT license.


All versions of doctrine2bridge with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
doctrine/orm Version 2.*
doctrine/migrations Version 1.0.*@dev
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package opensolutions/doctrine2bridge contains the following files

Loading the files please wait ....