How to use composer packages in codeigniter?

Tjorriemorrie picture Tjorriemorrie · Dec 6, 2012 · Viewed 47.7k times · Source

I've followed this article: http://philsturgeon.co.uk/blog/2012/05/composer-with-codeigniter

But I get Fatal error: Class 'Buzz\Browser' not found.

What is missing from his post?

My controller or application isn't namespaced. I was hoping to just be able to use that one package in one controller's action in a non-namespaced framework.

Answer

SeanWM picture SeanWM · Nov 15, 2016

For CodeIgniter 3.x and composer, it's suggested to just set $config['composer_autoload'] to TRUE or a custom path in application/config/config.php.

It seems that CI assumes the vendor directory is within the application directory. That wasn't my case. I did the following:

$config['composer_autoload'] = 'vendor/autoload.php';