Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

[Solved] Autoloading core classes and composer

$
0
0
Well, the title is sorta right.

Here's what I'm trying to do:

Autoload classes in application/core.  IE: Admin_controller and Public_controller.  

I've done this in application/config with the following code (which works)

PHP Code:
function __autoload($class)
{
 if(
strpos($class'CI_') !== 0)
 {
 
 @include_once( APPPATH 'core/'$class '.php' );
 }



I'm also trying to use a composer package, (Stripe if it matters)

I've tried this in application/config.php (the normal place) and in the project root file index.php

PHP Code:
$config['composer_autoload'] =  'vendor/autoload.php'

Which does work but...

They don't work together at the same time.  If composer autoloading is 'on' the Admin_controller I get the error:
PHP Code:
Fatal error: Class 'Admin_Controller' not found in... 


When I turn composer autoloading back off, the Admin_controller is loaded and works correctly.  

I've tested this in PHP 5 and 7.1 with CI 3.1.3 - 3.1.6

So, my question is how do I get them both going at the same time?  Any help is appreciated.

Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>