Tjorriemorrie Tjorriemorrie - 18 days ago 5
PHP Question

How to use composer packages in codeigniter?

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

Credit to @jmadsen

This is possible by just getting the order of loading correct:

/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *
 * And away we go...
 *
 */
// Composer Autoloader
require FCPATH . 'vendor/autoload.php';

require_once BASEPATH.'core/CodeIgniter.php';

/* End of file index.php */
Comments