doulie0178 2015-08-27 23:08
浏览 55
已采纳

DoctrineExtensions查找错误的目录

I'm using Doctrine ORM in my PHP project.

In one of my queries I'm using the 'COS' (cosine) and 'SIN' (sine) functions, in order to make this possible on Doctrine I have to add this to my entitymanager configuration:

$config->addCustomNumericFunction('COS', 'DoctrineExtensions\Query\Mysql\cos');
$config->addCustomNumericFunction('SIN', 'DoctrineExtensions\Query\Mysql\sin');

This works fine when I run it on my local PC + server.

But once I put the project on the online webserver I'm facing with these errors:

Fatal error: Class 'DoctrineExtensions\Query\Mysql\cos' not found in /home/USER/domains/USER.com/public_html/MYDIRECTORY/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php on line 3418

Fatal error: Class 'DoctrineExtensions\Query\Mysql\sin' not found in /home/USER/domains/USER.com/public_html/MYDIRECTORY/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php on line 3418

It's looking in the 'vendor\doctrine' directory instead of the 'vendor\beberlei\DoctrineExtensions' directory.

My composer contains:

"beberlei/DoctrineExtensions": "dev-master"

And the vendor autoloader contains:

'DoctrineExtensions\\' => array($vendorDir . '/beberlei/DoctrineExtensions/src')

Can anyone explain this to me... I tried adding a classloader, but still the same problem.

Localhost is working fine...

  • 写回答

1条回答 默认 最新

  • dongzongzhi6953 2015-08-28 14:12
    关注

    When adding sine and cosine functions to the entitymanager config I used:

    $config->addCustomNumericFunction('COS', 'DoctrineExtensions\Query\Mysql\cos');
    $config->addCustomNumericFunction('SIN', 'DoctrineExtensions\Query\Mysql\sin');
    

    The solution above is working on a local PC + server.

    When moving the project files to the webserver the above config won't work.

    You have to change the first letter of the last word in the DoctrineExtensions namespace to uppercase, like this:

    $config->addCustomNumericFunction('COS', 'DoctrineExtensions\Query\Mysql\Cos');
    $config->addCustomNumericFunction('SIN', 'DoctrineExtensions\Query\Mysql\Sin');
    

    Basically cos becomes Cos and sin becomes Sin .

    Now it works on the online webserver. Finally got it working!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改