Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use composer packages in codeigniter?

Tags:

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.

like image 367
Tjorriemorrie Avatar asked Dec 06 '12 10:12

Tjorriemorrie


People also ask

Can we use composer in CodeIgniter?

You can download the latest version from the CodeIgniter website, or you can use composer to automate the installation. The composer is a package management system for PHP. A composer can be used for: Install individual packages, Update existing packages remove installed packages.

What is third party in CodeIgniter?

To segment these third party libraries with your own libraries, CodeIgniter has brought a new segmented folder i.e. third party folder. So, if you are using CodeIgniter then you have to put that third party API libraries within the same library folder where you have kept or created your own application libraries.


1 Answers

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';

like image 178
SeanWM Avatar answered Sep 26 '22 01:09

SeanWM