CodeIgniter Forums
Extending Autoloader - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Extending Autoloader (/showthread.php?tid=77727)



Extending Autoloader - byazrail - 10-11-2020

Hello,

I made make to CodeIgniter\Autoloader\Autoloader extends.

Normally services extends after errors;
Fatal error: Uncaught Error: Class 'App\CoreExtends\Autoloader' not found
Code:
# Time Memory Function Location
1 0.0000 416496 {main}( ) .../rewrite.php:0
2 0.0001 419648 require_once( '/home/user/public_html/dev/public/index.php' ) .../rewrite.php:26
3 0.0002 420928 require( '/home/user/public_html/dev/core/bootstrap.php' ) .../index.php:115
4 0.0019 441952 Config\Services::autoloader( ) .../bootstrap.php:137

App\Config\Services;

PHP Code:
public static function autoloader(bool $getShared true)
{
    if (
$getShared)
    {
        if (empty(static::
$instances['autoloader']))
        {
            static::
$instances['autoloader'] = new \App\CoreExtends\Autoloader();
        }

        return static::
$instances['autoloader'];
    }

    return new \
App\CoreExtends\Autoloader();


\App\CoreExtends\Autoloader;
PHP Code:
<?php namespace App\CoreExtends;

class 
Autoloader extends \CodeIgniter\Autoloader\Autoloader
{



The purpose for me to do this process.
I need composerFile autoload like Composer.
Sample;

Composer.json
Code:
"autoload": {
    "psr-4": {"MyClass \\": "src /"},
    "files": ["src / functions.php"]
},