PHP code example of serebro / phalcon-service-loader
1. Go to this page and download the library: Download serebro/phalcon-service-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/ */
serebro / phalcon-service-loader example snippets
defined('APP_PATH') || define('APP_PATH', dirname(__FILE__) . '/../app');
defined('WEB_PATH') || define('WEB_PATH', dirname(__FILE__));
defined('ENV') || define('ENV', getenv('ENV') ? getenv('ENV') : 'development');
$services = APP_PATH . '/config/services.php'; // OR $services = APP_PATH . '/config/' . ENV . '.php';
//Create a DI
$di = new Phalcon\DI\FactoryDefault();
// Service loading
$serviceLoader = new \Phalcon\DI\Service\Loader($di);
$serviceLoader->setDefinitions($services, ['loader', 'env']);
//Handle the request
$app = new \Phalcon\Mvc\Application($di);
echo $app->handle()->getContent();