2017 © Pedro Peláez
 

library phprest-service-orm

Phprest Orm Service.

image

phprest/phprest-service-orm

Phprest Orm Service.

  • Sunday, June 28, 2015
  • by phprest
  • Repository
  • 1 Watchers
  • 1 Stars
  • 303 Installations
  • PHP
  • 3 Dependents
  • 1 Suggesters
  • 0 Forks
  • 1 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Phprest Orm Service

Author Software License, (*1)

Description

Orm Service which uses these components: * Doctrine\Orm * Doctrine\Migrations * Doctrine\Data-Fixtures, (*2)

Installation

Install it through composer., (*3)

{
    "require": {
        "phprest/phprest-service-orm": "@stable"
    }
}

tip: you should browse the phprest/phprest-service-orm page to choose a stable version to use, avoid the @stable meta constraint., (*4)

Usage

Configuration

For the configuration you should check the Config class., (*5)

Example

<?php
$ormConfig = new \Phprest\Service\Orm\Config(
    [
        'driver'            => 'pdo_mysql',
        'host'              => 'localhost',
        'dbname'            => 'phprest',
        'charset'           => 'utf8',
        'user'              => 'root',
        'password'          => 'root'
    ],
    ['path_to_the_entities']
);

$ormConfig->migration = new \Phprest\Service\Orm\Config\Migration('path_to_the_migrations');
$ormConfig->fixture = new \Phprest\Service\Orm\Config\Fixture('path_to_the_fixtures');

Registration

<?php
use Phprest\Service\Orm;
# ...
/** @var \Phprest\Application $app */

$app->registerService(new Orm\Service(), $ormConfig);
# ...

Reaching from a Controller

To reach your Service from a Controller you should use the Service's Getter Trait., (*6)

<?php namespace App\Module\Controller;

use Phprest\Service;

class Index extends \Phprest\Util\Controller
{
    use Service\Orm\Getter;

    public function post(Request $request)
    {
        /** @var \Doctrine\ORM\EntityManager $em */
        $em = $this->serviceOrm();
    }
}

Cli

You can use a helper script if you want after a composer install (vendor/bin/phprest-service-orm)., (*7)

You have to provide an orm config for the script. You have two options for this: * Put your orm configuration to a specific file: app/config/orm.php * You have to return with the orm configuration in the proper file * Put the path of the configuration in the paths.php file * You have to return with an array from the paths.php file with the orm configuration file path under the service.orm.config array key, (*8)

The Versions

28/06 2015

dev-master

9999999-dev

Phprest Orm Service.

  Sources   Download

MIT

The Requires

 

orm database api service framework rest restful rdbms