PHP Classes

File: depdency.php

Recommend this page to a friend!
  Classes of Vitalij Mik   Doctrine PHP ORM Example   depdency.php   Download  
File: depdency.php
Role: Configuration script
Content type: text/plain
Description: Configuration script
Class: Doctrine PHP ORM Example
Examples of storing objects using Doctrine
Author: By
Last change:
Date: 2 years ago
Size: 916 bytes
 

Contents

Class file image Download
<?php

use Doctrine\ORM\Configuration;
use
Doctrine\ORM\EntityManager;
use
Doctrine\ORM\EntityManagerInterface;
use
Doctrine\ORM\Tools\Setup;

require_once
__DIR__.'/vendor/autoload.php';

$container= [];

$container['db'] = [
   
'driver' => 'pdo_mysql',
   
'user' => 'root',
   
'password' => '',
   
'dbname' => 'shop',
   
'charset' => 'utf8'
];
$container['env']= 'dev';


$container[Configuration::class] = function () use($container){

   
$isDevelopment = $container['env'] === 'dev';

    return
Setup::createAnnotationMetadataConfiguration(
        [
           
__DIR__.'/src/Entity'
       
],$isDevelopment,null,null,false
   
);
};

$container[EntityManagerInterface::class] = function() use($container){
   
$connection = $container['db'];
   
$annotationConfiguration = $container[Configuration::class]();
    return
EntityManager::create($connection,$annotationConfiguration);
};
return
$container;