0

I use PhpStorm, it shows Imagick class as available: Imagick on PhpStorm

I get list of the available functions too.

But when I use $imagick = new \Imagick(realpath($filename)); or $imagick = new Imagick(realpath($filename));

I get "class not found error".

Does it mean the Imagick class is available?

If Imagick is available, how can I use that class?

I have imagick.php inside php.jar, that file only cointains function signatures, the functions are empty.

Coder88
  • 1,015
  • 3
  • 10
  • 23
  • 1
    PHPStorm scan your project files, php library files and create index for autocompletion feature. This doesn't resolve problems. If you see errors in PHP then `Imagick` missing in your php installation. Check from console: `php -i | grep imagick` – Pavel Musil May 02 '20 at 17:34
  • 1
    Please update your question with what `phpinfio()` displays for the imagick extension, something like: https://i.imgur.com/yA1vnah.png – Will B. May 02 '20 at 17:43
  • 1
    php.jar is the internal PHPStorm library reference, it is how PHPStorm shows the details for autocomplete and usage, they are not a part of your PHP application. – Will B. May 02 '20 at 17:46
  • @fyrye nothing found about Imagick when I see phpinfo(). So that means well it doesn't exist. – Coder88 May 02 '20 at 17:49
  • 1
    Imagick is a PECL extension for PHP, it has to be enabled in your `php.ini` file as an extension.For windows based installation see my answer: https://stackoverflow.com/a/30295211/1144627 For Linux distributions, you need to install it with your yum/apt-get package manager for your version of PHP. – Will B. May 02 '20 at 17:53

1 Answers1

1

For code completion PhpStorm collects entries from the code in your project (code written in PHP) and from own stubs for PHP core functions and other common PHP extensions (as those extensions are compiled binary files (.dll/.so file) usually written in C).

You can Ctrl + Click on that class in the IDE and it will take you to the class declaration, which will be one of the stub files.

Imagick is a native PHP extension and you have to make sure that you actually have it installed in your PHP to have your code working properly.

https://www.php.net/manual/en/imagick.installation.php


You can tell PhpStorm to only include stub entries for what you actually have installed in your current PHP Interpreter. This way you will not have entries in Code Completion for classes/functions that come from not-available-in-your-setup extensions.

Check Settings/Preferences | Languages & Frameworks | PHP, "PHP Runtime Tab" tab for that.

https://www.jetbrains.com/help/phpstorm/php.html#php-runtime-tab

LazyOne
  • 158,824
  • 45
  • 388
  • 391