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...
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!