Welcome Guest, Not a member yet? Register   Sign In
Doctrine integration
#15

Hello,
Very interested by this solution, so i tried it. 
But Doctrine version is higher and code exposed here does not work anymore.
So i picked code for App\Libraries\doctrine.php in doctrine "installation and configuration" page (didn't kept
Code:
require_once "vendor/autoload.php";
line)
PHP Code:
namespace App\Libraries;

use 
Doctrine\DBAL\DriverManager;
use 
Doctrine\ORM\EntityManager;
use 
Doctrine\ORM\ORMSetup;

use 
CodeIgniter\Config\BaseConfig;
use 
Config\Database as DbConfig;

class 
Doctrine
{
    public $entityManager;
    public function __construct()
    {        
        $dbConfig 
config(DbConfig::class);
        $dbParams = [
            'driver'  => strtolower($dbConfig->default['DBDriver']),
            'user'    => $dbConfig->default['username'],
            'password' => $dbConfig->default['password'],
            'dbname'  => $dbConfig->default['database'],
            'host'    => $dbConfig->default['hostname'],
        ];        
        $config 
ORMSetup::createAttributeMetadataConfiguration(
            paths: array(__DIR__."/../app/Models/Entities"),
            isDevModetrue,
        );
        $connection DriverManager::getConnection($dbParams$config);      
        $entityManager 
= new EntityManager($connection$config);
    }

Kept Service.php like exposed here.
No error messages but, in home.php controller
PHP Code:
        $entityManager service('doctrine');
        d($entityManager); 
displays NULL
Can someone help ?
Will tatter/relations be modified to comply to the requirements of v4.5.1 version?
Thanks
Eric
Reply


Messages In This Thread
Doctrine integration - by ScientiFist - 11-16-2019, 08:26 PM
RE: Doctrine integration - by MGatner - 11-17-2019, 04:39 AM
RE: Doctrine integration - by InsiteFX - 11-17-2019, 04:50 AM
RE: Doctrine integration - by ScientiFist - 11-17-2019, 05:58 PM
RE: Doctrine integration - by MGatner - 11-17-2019, 05:10 AM
RE: Doctrine integration - by MGatner - 11-18-2019, 05:31 AM
RE: Doctrine integration - by ScientiFist - 11-18-2019, 10:34 AM
RE: Doctrine integration - by jasonzig - 11-29-2019, 08:20 AM
RE: Doctrine integration - by MGatner - 11-18-2019, 04:24 PM
RE: Doctrine integration - by ScientiFist - 11-26-2019, 06:29 PM
RE: Doctrine integration - by ScientiFist - 11-30-2019, 07:25 AM
RE: Doctrine integration - by MGatner - 12-01-2019, 05:36 AM
RE: Doctrine integration - by troturier - 12-06-2019, 06:28 AM
RE: Doctrine integration - by ScientiFist - 03-17-2020, 07:06 PM
RE: Doctrine integration - by foxbille - 05-10-2024, 11:51 PM
RE: Doctrine integration - by kenjis - 05-11-2024, 02:17 AM
RE: Doctrine integration - by foxbille - 05-11-2024, 05:24 AM
RE: Doctrine integration - by kenjis - 05-13-2024, 06:57 PM
RE: Doctrine integration - by foxbille - 05-18-2024, 09:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB