CodeIgniter Forums
CI 3 & composer - 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: CI 3 & composer (/showthread.php?tid=64487)



CI 3 & composer - BrendanRehman - 02-24-2016

So heres something really cool about CI3. You get all the core features of which there are many... and you can always add more, just like any other framework CI 3 supports composer packages. Here's a quick summary:

CI3 allows you to autoload composer packages via your config file.

Edit your config.php file and set the following:

PHP Code:
$config['composer_autoload'] = TRUE

Next, and since CI3 looks for the vendor folder in application/vendor we need to tell composer where to store our composer packages.

So open your composer.json file and add the following line to the top of the file.

Code:
"config": {
"vendor-dir": "application/vendor"
},

Now lets assume you want to use the symfony dump() command to debug your code. Simply run this from the command line.

composer require symfony/var-dumper

Let composer do its thing... and once done you're ready to roll.

PHP Code:
$users $this->users->get_all();
dump($users); //symfony dump library 

Voila, you're done. Fraekin powerful and now you can use all the packages available from http://www.packagist.org

Enjoy.