Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 56 lines (47 sloc) 1.25 KB
<?php
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Di\FactoryDefault;
use Phalcon\Loader;
use Phalcon\Mvc\Application;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Mvc\View;
define('BASE_PATH', dirname(__DIR__));
define('APP_PATH', BASE_PATH . '/app');
// Register an autoloader
$loader = new Loader();
$loader->registerDirs(
[
APP_PATH . '/controllers/',
APP_PATH . '/models/',
]
)->register();
// Create a DI
$di = new FactoryDefault();
// Setting up the view component
$di['view'] = function () {
$view = new View();
$view->setViewsDir(APP_PATH . '/views/');
return $view;
};
// Setup a base URI so that all generated URIs include the "tutorial" folder
$di['url'] = function () {
$url = new UrlProvider();
$url->setBaseUri('/');
return $url;
};
// Set the database service
$di['db'] = function () {
return new DbAdapter([
"host" => getenv('DATA_MYSQL_HOST'),
"username" => getenv('DATA_MYSQL_USER'),
"password" => getenv('DATA_MYSQL_PASS'),
"dbname" => "gonano",
]);
};
// Handle the request
try {
$application = new Application($di);
echo $application->handle()->getContent();
} catch (Exception $e) {
echo "Exception: ", $e->getMessage();
}
You can’t perform that action at this time.