Using Imagick in Symfony2

Using Imagick in Symfony2?

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

new \Imagick;

This will make PHP not look for the class Imagick within the current namespace.

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

Attempted to load class Imagick from the global namespace in symfony3

I found the solution, I put the answer for someone who have the same issue:

you should add the following lines

;on Windows:
extension=php_imagick.dll
;on UNIX:
extension = imagick.so

to C:\wamp64\bin\php\phpx.x.x\php.ini

not to C:\wamp64\bin\apache\apachex.x.x\bin\php.ini

because the first php.ini is the file used by PHP CLI, so by the Symfony Local Web Server.

Happy coding!

Permission issue with Imagick and user www-data

Can you use PHP chmod

chmod('path/new_filename.jpg', 0755);

after creating file?

How to use the 'raw' PHP Mongodb PECL driver within Symfony2

Symfony2 works with namespace php. This makes working with non-namespace libraries/classes a bit tricky, but you really just need to know the tricks.

When you try to use new Mongo() to grab a mongodb object, PHP looks in your current namespace, which means it looks for a mongo() function within your class. To make this work, you need to specify the namespace for mongo. Since it does not use namespaces, PHP places it in the global namespace . So, to correctly reference the function, you need to use new \Mongo(), and PHP will look in your \ namespace instead of your current one.

Imagick php windows

I spent many hours trying to make Imagick work, finally I got it.

My installation instructions

  1. Install WAMP 32bit (even if you running 64bit system you must use 32bit version of WAMP)
  2. Install ImageMagick to C:/imagemagick, use this file: https://www.dropbox.com/s/i2mhrhd7sp0ilzk/ImageMagick-6.8.0-3-Q16-windows-dll.exe
  3. Put DLL with Imagick into extension folder of PHP, e.g. D:\wamp32\bin\php\php5.4.16\ext, I used this file: https://www.dropbox.com/s/ayankf850l08rm2/php_imagick.dll
  4. In php.ini put line "SetEnv MAGICK_HOME C:/imagemagick" without quotes
  5. Better restart PC

I use Wamp 2.4, PHP 5.4.16, Apache 2.4.4, ImageMagick 6.8.0-3 2012-10-24 Q16, Imagick 3.1.0RC2 - all 32bit, OS Win8 64bit

Now it should work and you should see Imagick extension loaded in phpinfo.

I tried a lot of versions of ImageMagick, but newer versions didn't work, 6.8.0-3-Q16-windows-dll works fine.

Symfony2

In Symfony2 use Imagick like this:

$im = new \Imagick('image.jpg');


Related Topics



Leave a reply



Submit