Doctrine handler middleware for Slim Framework.
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';
Just add as any other middleware.
use Slim\Slim;
use Jgut\Slim\Middleware\DoctrineMiddleware;
$app = new Slim();
...
$app->add(new DoctrineMiddleware());
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);
connection
array of PDO configurationsannotation_paths
array of paths where to find entities filesannotation_files
array of Doctrine annotations filesannotation_namespaces
array of Doctrine annotations namespacesannotation_autoloaders
array of Doctrine annotations utoloadersproxy_path
string, path were Doctrine creates it's proxy classes, defaults to /tmp
Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before
See file CONTRIBUTING.md
See file LICENSE included with the source code for a copy of the license terms