Muhammad Wajahat Anwar
Muhammad Wajahat Anwar

Reputation: 1065

Composer autoload is overriding codeigniter autoload

I am using composer. Composer autoload file is in the application/vendor/autoload.php. In codeigniter 3 I set ["composer_autoload"] = true in config. But it is overriding the main autoload of the codeigniter and couldn't able to load the Main classes of codeigniter and my codeigniter libraries. What should i do?

Upvotes: 1

Views: 573

Answers (1)

Muhammad Wajahat Anwar
Muhammad Wajahat Anwar

Reputation: 1065

At the end of the config file there is comment like below just uncomment it.

spl_autoload_register( function ( $class ) {
    $file = "sources/" . $class . ".class.php";
    if ( file_exists( $file ) ) {
        require $file;
        return;
    }
} );
  1. Make $config['composer_autoload'] = FALSE;

  2. Then add ( require FCPATH . 'application/vendor/autoload.php'; ) below the spl_autoload_resgister function.

Upvotes: 1

Related Questions