phpphantomjscomposer-phpphp-phantomjs

Composer + PhantomJS: Why is the class not found?


I am trying to install PHP PhantomJS package in a blank project, but I am getting this error:

Fatal error: Class 'JonnyW\PhantomJs\Client' not found

This is my composer.json:

enter image description here

And this is my index.php:

enter image description here

Can anyone tell why is the class not found? I suspect something is wrong in composer.json but I cannot figure out what.


Solution

  • The file is not found, because the index.php misses to include the Composer Autoloader.

    Please add the following line at the top:

    require __DIR__ . '/../vendor/autoload.php';
    

    (I wonder why you are working directly inside the JonnyW/PhantomJS project folder and not inside your own project? Anyway...)