CodeIgniter Forums
"Use" Command with CI? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: "Use" Command with CI? (/showthread.php?tid=67512)



"Use" Command with CI? - VikRubenfeld - 03-02-2017

I've installed PhantomJS and PHP-PhantomJS per the PHP-PhantomJS docs.

Per the PHP-PhantomJS docs, I have the following lines at the top of a controller file:

Code:
   use JonnyW\PhantomJs\Client;
   $client = Client::getInstance();

When executing `$client = Client::getInstance();`, I get the error:

Quote:'JonnyW\PhantomJs\Client' not found

The installer has placed `JonnyW\PhantomJs\Client` here:

Quote:/Applications/myWebApp/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Client.php

The controller that contains the "use" command is located here:

Code:
/Applications/myWebApp/application/controllers/myController.php

How can I modify the "use" command so as to locate the required "JonnyW\PhantomJs\Client" file?

Thanks in advance to all for any info.


RE: "Use" Command with CI? - albertleao - 03-03-2017

Is your composer turned on in your config file? Try running the command 'sudo dump-autoload' wherever your composer.json file is stored.


RE: "Use" Command with CI? - VikRubenfeld - 03-03-2017

I've used npm a lot for node.js, but this is my first time using Composer (with PHP of course). Here is my current composer.json file, (which is located in the same directory as index.php):

Code:
{
        "require": {
            "jonnyw/php-phantomjs": "4.*"
        },
        "config": {
            "bin-dir": "bin"
        },
        "scripts": {
            "post-install-cmd": [
                "PhantomInstaller\\Installer::installPhantomJS"
            ],
            "post-update-cmd": [
                "PhantomInstaller\\Installer::installPhantomJS"
            ]
        }
    }

What is the correct way to modify this file so as to turn on composer?


RE: "Use" Command with CI? - koficypher - 03-03-2017

Navigate to your application/config/config.php file and set
$config['composer_autoload'] = TRUE; //around 134 line


RE: "Use" Command with CI? - VikRubenfeld - 03-03-2017

That worked. Thanks!


RE: "Use" Command with CI? - koficypher - 03-03-2017

(03-03-2017, 03:48 AM)VikRubenfeld Wrote: That worked. Thanks!

You welcome