How to use composer packages in codeigniter?

后端 未结 7 1694
逝去的感伤
逝去的感伤 2020-12-02 17:38

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.<

7条回答
  •  爱一瞬间的悲伤
    2020-12-02 18:12

    There are two ways you can autoload the class file which is required using composer.

    1. Add below line in index.php in the root directory.

      require FCPATH . 'vendor/autoload.php';
      
    2. Or autoload directly in the controller where you want to use.

      defined('BASEPATH') OR exit('No direct script access allowed');
      
      require FCPATH . 'vendor/autoload.php';
      
      class Home extends CI_Controller {...}
      

提交回复
热议问题