mitchellvanw/laravel-doctrine


NO LONGER MAINTAINED! A Doctrine 2 implementation that melts with Laravel

License: MIT

Language: PHP


Doctrine 2 for Laravel (NO LONGER MAINTAINED! Try laravel-doctrine/orm instead!)

Latest Stable Version License Total Downloads

A Doctrine 2 implementation that melts with Laravel 4.

Documentation

Begin reading the full documentation here or go to a specific chapter right away.

  1. Installation
  2. How It Works
    1. Basics
    2. Entity Manager
    3. Timestamps
    4. Soft Deleting
    5. Authentication
  3. Schemas
  4. Doctrine Configuration
    1. Metadata Configuration
    2. Annotation Reader
    3. Metadata
  5. MIT License

Caveats

At the moment Doctrine\migrations version 1.0 is still in alpha. As a result the composer install may require you to change the minimum-stability in your composer.json to dev.

If you don't want to affect the stability of the rest of the packages, you can add the following property in your composer.json:

"prefer-stable": true

Installation

Begin by installing the package through Composer. Edit your project's composer.json to require mitchellvanw/laravel-doctrine.

This package is still in it's early stages, but fully functional. Is it possible that the API might change slightly, no drastic changes.

"require": {
    "mitchellvanw/laravel-doctrine": "0.5.*"
}

Next use Composer to update your project from the the Terminal:

php composer.phar update

Once the package has been installed you'll need to add the service provider. Open your app/config/app.php configuration file, and add a new item to the providers array.

'Mitch\LaravelDoctrine\LaravelDoctrineServiceProvider'

After This you'll need to add the facade. Open your app/config/app.php configuration file, and add a new item to the aliases array.

'EntityManager' => 'Mitch\LaravelDoctrine\EntityManagerFacade'

It's recommended to publish the package configuration.

php artisan config:publish mitchellvanw/laravel-doctrine --path=vendor/mitchellvanw/laravel-doctrine/config

2 Minutes

This package uses the Laravel database configuration and thus it works right out of the box. With the Entity Manager facade (or service locator) you can interact with repositories. It might be wise to check out the Doctrine 2 docs to know how it works. The little example below shows how to use the EntityManager in it simplest form.

<?php

$user = new User;
$user->setName('Mitchell');

EntityManager::persist($user);
EntityManager::flush();

The User used in the example above looks like this.

<?php

use Doctrine\ORM\Mapping AS ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
class User
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string")
     */
    private $name;

    public function getId()
    {
        return $this->id;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($name)
    {
        $this->name = $name;
    }
}

If you've only used Eloquent and its models this might look bloated or frightening, but it's actually very simple. Let me break the class down.

<?php

use Doctrine\ORM\Mapping AS ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
class User
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string")
     */
    private $name;
}

The only thing that's actually important in this entity are the properties. This shows you which data the entity holds.

With Doctrine 2 you can't interact with database by using the entity User. You'll have to use Entity Manager and repositories. This does create less overhead since your entities aren't extending the whole Eloquent model class. Which can dramatically slow down your application a lot if you're working with thousands or millions of records.

License

This package is licensed under the MIT license.

Project Statistics

Sourcerank 6
Repository Size 1.1 MB
Stars 202
Forks 86
Watchers 14
Open issues 35
Dependencies 6
Contributors 14
Tags 18
Created
Last updated
Last pushed

Top Contributors See all

Mitchell van Wijngaarden Kirk Bushell Antoine Bluchet Glenn Jacobs Luciano Longo Guido Contreras Woda bangipul Matt Foxx Jeremy Worboys Leonardo Alifraco Logan Bailey Sam Greenwood sephv psampaz

Packages Referencing this Repo

mitchellvanw/laravel-doctrine
The Doctrine 2 implementation that melts with Laravel 4
Latest release 0.6.x-dev - Updated - 202 stars
mitch/laravel-doctrine
The Doctrine 2 implementation that melts with Laravel 4
Latest release 0.6.x-dev - Updated - 202 stars

Recent Tags See all

0.5.0 September 22, 2014
0.4.3 September 16, 2014
0.4.2 September 07, 2014
0.4.1 September 07, 2014
0.4.0 August 10, 2014
0.3.4 May 13, 2014
0.3.3 May 11, 2014
0.3.2 May 10, 2014
0.3.1 May 08, 2014
0.3.0 May 08, 2014
0.2.4 May 07, 2014
0.2.3 May 07, 2014
0.2.2 May 07, 2014
0.2.1 May 05, 2014
0.2 May 05, 2014

Interesting Forks See all

FoxxMD/laravel-doctrine
A Doctrine 2 implementation that melts with Laravel
PHP - MIT - Last pushed - 13 stars - 9 forks
Maatwebsite/laravel-doctrine
A Doctrine 2 implementation that melts with Laravel
PHP - MIT - Last pushed - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2016-11-24 13:57:13 UTC

Login to resync this repository