PHP code example of level-2 / axel

1. Go to this page and download the library: Download level-2/axel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

level-2 / axel example snippets



$axel = new \Axel\Axel;

$axel = $axel->addModule($moduleName);


$axel = new \Axel\Axel;
$axel = $axel->addModule($moduleName);
$axel->register();


$axel = $axel->addModule(new \Axel\Module\PSR4('./lib/MyLibrary', '\\MyLibrary'));

new \MyLibrary\Foo();

$axel =  $axel->addModule(new \Axel\Module\PSR4('./lib/'));

new \MyLibrary\Foo();
new \MyOtherLibrary\Bar\Baz();

$axel = $axel->addModule(new \Axel\Module\PSR4('./lib/'));

new \MyLibrary\Foo();

$axel = $axel->addModule(new \Axel\Module\PSR4('./Conf', '\\Conf'));
$axel = $axel->addModule(new \Axel\Module\PSR4('./Models', '\\Models'));
$axel = $axel->addModule(new \Axel\Module\PSR4('./Controllers', '\\OnlineShop\\Controllers'));


$axel =  $axel->addModule(\Axel\Module\Composer($axel, './project'));


namespace Axel;
interface Module {
	public function locate($className);
}


namespace MyLibrary;
class MyAutoloader implements \Axel\Module {
	public function locate($className) {
		if ($className == 'MyClass') return __DIR__ . DIRECTORY_SEPARATOR . 'MyClass.php';
		else if ($className == 'OtherClass') return __DIR__ . DIRECTORY_SEPARATOR . 'OtherClass.php';
		else return false;
	}

}


$simpleCache = new \SimpleCache\SimpleCache('./tmp');

$axel = new \Axel\Axel($simpleCache);