Skip to content

mcrauwel/slim-doctrine-middleware

 
 

Repository files navigation

Build Status Code Climate Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads

Juliangut Slim Framework Doctrine handler middleware

Doctrine handler middleware for Slim Framework.

Installation

Best way to install is using Composer:

php composer.phar require juliangut/slim-doctrine-middleware

Then require_once the autoload file:

require_once './vendor/autoload.php';

Usage

Just add as any other middleware.

use Slim\Slim;
use Jgut\Slim\Middleware\DoctrineMiddleware;

$app = new Slim();

...

$app->add(new DoctrineMiddleware());

Configuration

There are two ways to configure Doctrine Middleware

First by using doctrine key in Slim application configuration

$config = [
    'doctrine' => [
        'connection' => [
            'driver' => 'pdo_sqlite',
            'memory' => true,
        ],
        'annotation_paths' => ['path_to_entities_files'],
    ],
];

$app = new Slim($config);
$app->add(new DoctrineMiddleware());

Second way is assigning options directly to Doctrine Middleware

$app = new Slim();

$doctrineMiddleware = new DoctrineMiddleware();
$doctrineMiddleware->setOption(
    'connection',
    ['driver' => 'pdo_sqlite', 'memory' => true]
);
$doctrineMiddleware->setOption('annotation_paths', ['path_to_entities_files']);
$app->add($doctrineMiddleware);

Available configurations

  • connection array of PDO configurations
  • annotation_paths array of paths where to find entities files
  • annotation_files array of Doctrine annotations files
  • annotation_namespaces array of Doctrine annotations namespaces
  • annotation_autoloaders array of Doctrine annotations autoloaders
  • cache_driver array, configuration of Doctrine cache
    • type type of cache you want to use, available types: apc, xcache, memcache, redis, array
    • host host of the caching daemon, needed for memcache, redis, defaults to '127.0.0.1'
    • port port of the caching daemon, optional, available for memcache (defaults to 11211), redis (defaults to 6379)
  • proxy_path string, path were Doctrine creates it's proxy classes, defaults to /tmp

Contributing

Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before

See file CONTRIBUTING.md

License

Release under BSD-3-Clause License.

See file LICENSE included with the source code for a copy of the license terms

About

Slim Framework Doctrine Middleware

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 88.4%
  • JavaScript 11.6%