PHP code example of mozart / loader
1. Go to this page and download the library: Download mozart/loader 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/ */
mozart / loader example snippets
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar
$ git clone https://github.com/FaizalPribadi/Loader.git /path/to/your-vendor/Loader
function findFile($file)
{
if (file_exists($file)) {
return @
findFile(__DIR__ . '/Framework/Mozart/Library/Loader/ClassLoader.php');
findFile(__DIR__ . '/Vendors/Symfony/Component/ClassLoader/UniversalClassLoader.php');
use Mozart\Library\Loader\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Mozart\Library\Cache\Driver\OpCache\Apc;
$loader = ClassLoader::bootstrap();
$loader->mapClass(array(
'Mozart' => __DIR__ . '/Framework',
'Doctrine' => __DIR__ . '/Vendors',
'Symfony' => __DIR__ . '/Vendors',
'Psr' => __DIR__ . '/Vendors',
'Monolog' => __DIR__ . '/Vendors',
'Metadata' => __DIR__ . '/Vendors/JMS/Metadata/src',
));
$loader->register();
$loader->setCache(new \Mozart\Library\Cache\Cache(new Apc()));
$loader->enableCache(true);
//TODO enable annotations parsing
AnnotationRegistry::registerLoader(function($class) use ($loader) {
$loader->findClassFile($class);
return class_exists($class, true);
});
AnnotationRegistry::registerFile(__DIR__ . '/Vendors/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');