Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: Installing doctrine in project

I am currently trying to run Doctrine in a custom (own) project, which isn't based on any popular framework.

I've been able to do the following for my current bootstrap.php;

<?php
require dirname(__FILE__) . '/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine', dirname(__FILE__) );
$classLoader->register(); // register on SPL autoload stack

However I have a strong feeling that this is far from enough and I can't find any documentation which clearly states what I should do next.

Running $conn = Doctrine_Manager::connection('mysql://root:[email protected]/myTable', 'doctrine'); will make my PHP file to start throwing errors (Fatal error: Class 'Doctrine_Manager' not found) - so I am pretty sure that I have not completed the bootstrap.php properly.

What should I do to make Doctrine run as intended in my own project?

like image 326
Industrial Avatar asked Nov 06 '22 03:11

Industrial


1 Answers

If you work your way through extensive doctrine documentation on the project website, it walks you through step by step what's required for a proper doctrine bootstrap

Added from comment on question

I'm fairly certain there is no Doctrine_Manager in Doctrine 2. There's an EntityManager. Doctrine_Manager::connection('mysql://root:[email protected]/myTable', 'doctrine'); this is Doctrine 1 code.

Either way, all classes should be namespaced \Doctrine_Manager

Here are some good reference for you:

Doctrine 1 to Doctrine 2

Doctrine 2 - Not the same old PHP ORM Slide 44 is what you are after

like image 69
xzyfer Avatar answered Nov 09 '22 13:11

xzyfer