File: /var/www/farm.kosmicfarms_backup/public/index.php
<?php
use Phalcon\Autoload\Loader;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Application;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Mvc\View;
use Phalcon\Debug;
define('BASE_PATH', dirname(__DIR__));
define('APP_PATH', BASE_PATH . '/app');
// Register an autoloader
$loader = new Loader();
$loader
->setDirectories(
[
APP_PATH . '/controllers/',
APP_PATH . '/models/',
]
)
->register()
;
// Create a DI
$container = new FactoryDefault();
$debug = new Debug();
$debug->listen();
// Setting up the view component
$container['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
$container['url'] = function () {
$url = new UrlProvider();
$url->setBaseUri('/');
return $url;
};
// Set the database service
$container['db'] = function () {
return new DbAdapter(
[
'host' => 'localhost',
'username' => 'BWaj3JLH',
'password' => 'KF7j.cQe',
'dbname' => 'JJpJF3Bb',
'port' => 3306,
'charset' => 'utf8', // Optional, but recommended
]
);
};
// Handle the request
try {
$application = new Application($container);
$response = $application->handle($_SERVER["REQUEST_URI"]);
$response->send();
} catch (Exception $e) {
echo "Exception: ", $e->getMessage();
}