I would like to use a COM object in my Symfony 2 Controller. COM must be a part of PHP 5, so I guessed there would have been no problem.
Here is my code:
$ObjectFactory = new COM("CrystalReports11.ObjectFactory.1");
And Symfony returns me this error:
Class 'App\InterfaceBundle\Controller\COM' not found
I’m on Windows 7, using PHP 5.3. When displaying phpinfo, I can see COM object support enabled.
What am I doing wrong? Is there any PHP inclusion to make in the Controller to make it work?
You’re working in a namespace called
App\InterfaceBundle\Controller, so PHP is looking for the classCOMwithin that namespace.Changing your code to the following will explicitly tell PHP to load the class from the “global space” rather than the current namespace:
You can read more about namespaces in the PHP manual: http://www.php.net/manual/en/language.namespaces.php