Using Imagick in Symfony2?

I try to use Imagick with Symfony2, but every time I try to use it, it causes the following error:

Fatal error: Class 'Acme\TestBundle\Services\Imagick' not found... 

I use Imagick in the service that I configured to manage my images. What do I need to do to be able to use this class?

I can confirm that the Imagick extension runs on the server and is used by other sites.

Thanks in advance for your help.

+4
source share
1 answer

When you instantiate the Imagick class, use the full quallified class-name:

 new \Imagick; 

This will cause PHP not to look for the Imagick class in the current namespace.

For a more detailed explanation, see a similar question / answer: Problems with PHP namespaces and built-in classes, how to fix it? and How to use the "root" php namespace? .

+12
source

All Articles