} //////////////////////////// // BOOTSTRAP other blocks $blockFolderArray = Host\Object\AppBlockCore::getBlockFolderArray(); foreach ($blockFolderArray as $blockFolder) { // IF block folder's bootstrap file exists if (file_exists($blockFolder . 'bootstrap.php')) { // RUN boostrap for block require_once $blockFolder . 'bootstrap.php'; } } //////////////////////////// // BIND LOADER $loader = new \Phalcon\Loader(); $loader->registerDirs($loaderDirArray); $loader->registerClasses($loaderClassArray); $loader->registerNamespaces($loaderNamespaceArray); $loader->register(); //////////////////////////// // SYNC PROJECT FOLDER if (SERVER == 'dev' && isset($_GET['refreshAll'])) { Host\Object\ExtenderCore::SyncProjectFolder(); } //////////////////////////// // VIEW SETUP $viewDirArray = array(); //////////////////////////// // ROOT $di->set('url', function () { $url = new \Phalcon\Mvc\Url(); $url->setBaseUri('/');
<?php // Creates the autoloader $loader = new \Phalcon\Loader(); // Register some classes $loader->registerClasses(array("Some" => "library/OtherComponent/Other/Some.php", "Example\\Base" => "vendor/example/adapters/Example/BaseClass.php")); // register autoloader $loader->register(); // Requiring a class will automatically include the file it references // in the associative array // i.e. library/OtherComponent/Other/Some.php $some = new Some();
error_reporting(E_ALL); define('APP_PATH', realpath('..')); try { //Autoloader $loader=new \Phalcon\Loader(); $loader->registerDirs([ '../app/controllers', '../app/models', '../app/config' ]); $loader->registerClasses([ 'Component\User'=>'../app/components/User.php', 'Component\Helper'=>'../app/components/Helper.php', ]); $loader->register(); //Dependency Injection $di=new \Phalcon\Di\FactoryDefault(); //Set Base URL $di->set('url', function() { $url = new \Phalcon\Mvc\Url(); $url->setBaseUri('http://localhost/xampp/phalcon-learning/'); return $url; }, true); //Database
public function testEvents() { $loader = new Phalcon\Loader(); $loader->registerDirs(array("unit-tests/vendor/example/other/")); $loader->registerClasses(array("AvecTest" => "unit-tests/vendor/example/other/Avec/")); $loader->registerNamespaces(array("Avec\\Test" => "unit-tests/vendor/example/other/Avec/")); $loader->registerPrefixes(array("Avec_" => "unit-tests/vendor/example/other/Avec/")); $eventsManager = new Phalcon\Events\Manager(); $trace = array(); $eventsManager->attach('loader', function ($event, $loader) use(&$trace) { $trace[$event->getType()] = $loader->getCheckedPath(); }); $loader->setEventsManager($eventsManager); $loader->register(); $test = new VousTest3(); $this->assertEquals(get_class($test), 'VousTest3'); $this->assertEquals($trace, array('beforeCheckClass' => NULL, 'beforeCheckPath' => 'unit-tests/vendor/example/other/VousTest3.php', 'pathFound' => 'unit-tests/vendor/example/other/VousTest3.php', 'afterCheckClass' => 'unit-tests/vendor/example/other/VousTest3.php')); $loader->unregister(); }
<?php // Creates the autoloader $loader = new \Phalcon\Loader(); $classMap = (require_once __DIR__ . '/../../vendor/composer/autoload_classmap.php'); //Register the class map $loader->registerClasses($classMap); // register autoloader $loader->register(); include __DIR__ . '/common.php';
/** * @param $namespace * @internal */ private function registerClass($namespace) { //registers task class in Class Loader $reflectionClass = new \ReflectionClass($namespace); $loader = new \Phalcon\Loader(); $loader->registerClasses(array($namespace => $reflectionClass->getFileName()), true); $loader->register(); }