php - Codeigniter2, Doctrine2, Composer ect. a huge mess -
php - Codeigniter2, Doctrine2, Composer ect. a huge mess -
all day i've been trying create work, unfortunately no success! follow tutorial of doctrine home page here
so got composer , download doctrine staff in vendor folder, took folder , set in codeigniter/application/library created file doctrine.php code:
use doctrine\orm\tools\setup; utilize doctrine\orm\entitymanager; class doctrine { public $em = null; public function __construct() { include apppath.'config/database.php'; require_once __dir__."/doctrine/vendor/autoload.php"; $paths = array(apppath.'models/entity'); $isdevmode = true; // connection configuration $dbparams = array( 'driver' => 'pdo_mysql', 'user' => $db['local']['username'], 'password' => $db['local']['password'], 'host' => $db['local']['hostname'], 'dbname' => $db['local']['database'], 'charset' => $db['local']['char_set'], ); $config = setup::createannotationmetadataconfiguration($paths, $isdevmode); $entitymanager = entitymanager::create($dbparams, $config); $this->em = $entitymanager; } } and has been saved in same path codeigniter/application/library
so have entity in models/entity folder looks this:
/** * @entity * @table(name="site_users") */ class menu { //... } and lastly code in contoller
$this->load->library('doctrine'); $em = $this->doctrine->em; $repository = $em->getrepository('entity\menu'); and i've got error
doctrine\common\persistence\mapping\mappingexception' message 'class 'entity\menu' not exist basically want utilize doctrine because gedmo tree extension, still can install doctrine extension if can help great in advance.
try $repository = $em->getrepository('menu');. dit not force menu within namespace, either set within namespace or utilize class name.
php codeigniter orm doctrine2
Comments
Post a Comment