Last active
November 29, 2018 21:32
-
-
Save roggeo/3cd2f3ffc894f9fb2b9851952a76fe4d to your computer and use it in GitHub Desktop.
Cli Config Doctrine ORM for Zend Framework 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Insert in config folder as file name cli-config.php | |
require_once "vendor/autoload.php"; | |
// bootstrap.php | |
use Doctrine\ORM\Tools\Setup; | |
use Doctrine\ORM\EntityManager; | |
use Doctrine\ORM\Tools\Console\ConsoleRunner; | |
// Create a simple "default" Doctrine ORM configuration for Annotations | |
$paths = array(__DIR__."/../module/Entities"); | |
$isDevMode = true; | |
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode, null, null, false); | |
// database configuration parameters | |
$conn = array( | |
'driver' => 'pdo_mysql', | |
'host' => 'localhost', | |
'port' => '3306', | |
'user' => 'root', | |
'password' => 'your_password', | |
'dbname' => 'your_dbname', | |
'charset' => 'utf8', | |
'driverOptions' => [ | |
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' | |
] | |
); | |
$entityManager = EntityManager::create($conn, $config); | |
return ConsoleRunner::createHelperSet($entityManager); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment