Giter Club home page Giter Club logo

orm's Introduction

Laravel Doctrine

GitHub release Travis Scrutinizer Packagist Packagist Packagist

This software is STILL IN DEVELOPMENT.

It is working software but breaking changes may occur with no prior warning. Do not use this in production!

For more information or to get started contributing visit us on Slack

A drop-in Doctrine ORM 2 implementation for Laravel 5+

  • Easy configuration
  • Pagination
  • Preconfigured metadata, connections and caching
  • Extendable: extend or add your own drivers for metadata, connections or cache
  • Change metadata, connection or cache settings easy with a resolved hook
  • Annotations, yaml, xml, config and static php meta data mappings
  • Multiple entity managers and connections
  • Laravel naming strategy
  • Simple authentication implementation
  • Password reminders implementation
  • Doctrine console commands
  • DoctrineExtensions supported
  • Timestamps, Softdeletes and TablePrefix listeners

Documentation

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

  1. Installation
  2. Basics
  3. Entities
  4. Meta Data
    1. Annotations
    2. YAML
    3. XML
    4. Config files
    5. StaticPHP
  5. EntityManager
  6. Multiple Connections
  7. Repositories
  8. Console Commands
  9. Configuration
  10. Connections
  11. Meta Data
  12. Caching
  13. Extensions
  14. Authentication
  15. Softdeletes
  16. Timestamps
  17. Table Prefixing
  18. DoctrineExtensions
  19. Writing your own extensions
  20. Configuration Migration
  21. Using the Configuration Migration Command
  22. Writing a template for configurations

Installation

Require this package in your composer.json and run composer update.

"laravel-doctrine/orm": "@dev"

After updating composer, add the ServiceProvider to the providers array in config/app.php

'LaravelDoctrine\ORM\DoctrineServiceProvider',

Optionally you can register the EntityManager facade:

'EntityManager' => 'LaravelDoctrine\ORM\Facades\EntityManager'

To publish the config use:

php artisan vendor:publish --tag="config"

Quick start

Out of the box this package uses the default Laravel connection which is provided in config/database.php, which means that you are ready to start fetching and persisting.

<?php

$article = new Article;
$article->setTitle('Laravel Doctrine Quick start');

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

Unlike Eloquent, Doctrine is not an Active Record pattern, but a Data Mapper pattern. Every Active Record model extends a base class (with all the database logic), which has a lot of overhead and dramatically slows down your application with thousands or millions of records. Doctrine entities don't extend any class. The domain/business logic is completely separated from the persistence logic. This means we have to tell Doctrine how it should map the columns from the database to our Entity class. In this example we are using annotations. Other possiblities are yaml, xml or php array's. The Article entity used in the example above looks like this.

<?php

use Doctrine\ORM\Mapping AS ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="articles")
 */
class Article
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    protected $id;

    /**
     * @ORM\Column(type="string")
     */
    protected $title;

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

    public function getTitle()
    {
        return $this->title;
    }

    public function setTitle($title)
    {
        $this->title = $title;
    }
}

To quickly create the articles table inside your database, run: php artisan doctrine:schema:update

Continue reading the full documentation.

License

This package is licensed under the MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.