很久以前所以我忘记了一些细节,但是我将这4个文件放在一个名为CodeIgniter / application / libraries / Doctrine / CustomAddon的文件夹中:
Distance.php
Point.php
PointStr.php
PointType.php
我将每个命名空间设置为“CustomAddon”。
然后在CodeIgniter / application / libraries / Doctrine.php的底部我放了:
require_once APPPATH . 'libraries/Doctrine/CustomAddon/Distance.php';
require_once APPPATH . 'libraries/Doctrine/CustomAddon/Point.php';
require_once APPPATH . 'libraries/Doctrine/CustomAddon/PointStr.php';
require_once APPPATH . 'libraries/Doctrine/CustomAddon/PointType.php';
Doctrine\DBAL\Types\Type::addType('point', 'CustomAddon\PointType');
//Assuming $config is a Doctrine\ORM\Configuration object used to configure the EM
$config->addCustomNumericFunction('DISTANCE', 'CustomAddon\Distance');
$config->addCustomNumericFunction('POINT_STR', 'CustomAddon\PointStr');
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);用法看起来像这样:
$point = new \CustomAddon\Point($geo['lat'], $geo['lon']);