Search code examples
phpphpstormimagick

PhpStorm class list


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.


Solution

  • 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