#5 | Phalcon\Mvc\Application->handle
/home/xpatlink/apps/xpatweb/public/index.php (262) <?php
// ini_set('display_errors', '1');
// ini_set('display_startup_errors', '1');
// error_reporting(E_ALL);
use Phalcon\Mvc\Router,
Phalcon\Mvc\Application,
Phalcon\DI\FactoryDefault,
Phalcon\Security,
Phalcon\Loader;
use Phalcon\Logger;
use Phalcon\Logger\Adapter\File as FileAdapter;
use Phalcon\Http\Cookie;
use Phalcon\Http\Response\Cookies;
use Phalcon\Logger\Adapter\Stream;
(new \Phalcon\Debug)->listen();
//echo phpinfo(); exit;
define('BASE_PATH', dirname(__DIR__));
define("BASE_URL", 'https://'. $_SERVER['HTTP_HOST']);
define('APP_PATH', BASE_PATH . '/Xpatlink');
define('HOMEIMAGE_PATH', BASE_PATH . '/public/images/homepage/');
define('CATEGORY_BANNER', BASE_PATH . '/public/images/categorybanners/');
define('MAGAZINE_PICTURE', BASE_PATH . '/public/images/issues/');
define('ADVERTS_PATH', BASE_PATH . '/public/images/xpatlink/');
define('ADTESTS_PATH', BASE_PATH . '/public/images/xpatlinktest/');
define('EVENTS_PATH', BASE_PATH . '/public/images/events/');
define('XPRESSION_PATH', BASE_PATH . '/public/images/xpression/');
define('XFOOD_PATH', BASE_PATH . '/public/images/xfood/');
define('XDEALS_PATH', BASE_PATH . '/public/images/xdeals/');
define('CATEGORYOG_PATH', BASE_PATH . '/public/images/categoryog/');
define('ROOT_PATH', dirname(__DIR__));
$config = include APP_PATH . "/Config/config.php";
//try {
/**
* The FactoryDefault Dependency Injector automatically registers
* the services that provide a full stack framework.
*/
$di = new FactoryDefault();
//Specify routes for modules
$di->set('router', function () {
$router = new Router();
$router->setDefaultModule("user");
$router->add(
"/:controller/:action",
array(
"module" => 'user',
"controller" => 1,
"action" => 2
));
// $router->add(
// "/:controller/:action/:params",
// array(
// "module" => 'user',
// "controller" => 1,
// "action" => 2,
// "params" => 3
// ));
$router->add('/:controller/:action/:params',
array(
"module" => 'user',
"controller"=>1,
"action"=>2,
"params"=>3
)
)->convert('action', function($action){
return lcfirst(Phalcon\Text::camelize($action));
});
return $router;
});
require_once(APP_PATH . '/Library/DiFile.php');
$di->setShared('connection', function () use ($config) {
return new \Phalcon\Db\Adapter\Pdo\Mysql([
"host" => $config->database->host,
"username" => $config->database->username,
"password" => $config->database->password,
"dbname" => $config->database->dbname,
]);
});
$di->setShared('session', function() {
// $session = new \Phalcon\Session\Adapter\Stream();
// $session->start();
// return $session;
$session = new Phalcon\Session\Manager();
$files = new Phalcon\Session\Adapter\Stream( [
'savePath' => '/tmp',
]);
$session->setAdapter($files)->start();
return $session;
});
// $di->setShared('random', function() {
// $random = new Phalcon\Security\Random();
// return $random;
// });
$di->set('flash', function () {
$flash = new \Phalcon\Flash\Direct (
array(
'error' => 'alert alert-danger',
'success' => 'alert alert-success',
'notice' => 'alert alert-info',
'warning' => 'alert alert-warning'
)
);
return $flash;
});
$di->setShared('flashSession', function () {
$flash = new \Phalcon\Flash\Session (
// array(
// 'error' => 'alert alert-danger',
// 'success' => 'alert alert-success',
// 'notice' => 'alert alert-info',
// 'warning' => 'alert alert-warning'
// )
);
return $flash;
});
$di->set(
"logger",
function () {
$logger = new FileAdapter("__DIR__ . '/../../Xpatlink/logger.log");
return $logger;
}
);
$di->setShared('controllerPath', function () {
if (!empty($_SERVER['REQUEST_URI'])) {
$uriParts = explode('?', $_SERVER['REQUEST_URI']);
$segment = explode('/', $uriParts[0]);
// $uri = str_replace('/', '', $uriParts[0]);
$uri = $segment[1].'/';
} else {
$uri = '/';
}
return $uri;
});
$di->set('users',function () {
include APP_PATH . '/Services/Users.php';
return new Users();
},
true
);
$di->set('categories',function () {
include APP_PATH . '/Services/Categories.php';
return new Categories();
},
true
);
$di->set('advertise',function () {
include APP_PATH . '/Services/Advertise.php';
return new Advertise();
},
true
);
$di->set('directpay',function () {
include APP_PATH . '/Services/Directpay.php';
return new Directpay();
},
true
);
$di->set('item',function () {
include APP_PATH . '/Services/Item.php';
return new Item();
},
true
);
$di->set('redis',function () {
include BASE_PATH . '/vendor/autoload.php';
include BASE_PATH . '/vendor/predis/Autoloader.php';
Predis\Autoloader::register();
/* $client = new Predis\Client();
$client->set('foo', 'bar');
$value = $client->get('foo');*/
$redis = new Predis\Client(array(
"scheme" => "tcp",
"host" => "127.0.0.1",
"port" => 6379
));
return $redis;
});
$application = new \Phalcon\Mvc\Application($di);
//Create an application
// Register the installed modules
$application->registerModules(
array(
'user' => array(
'className' => 'Xpatlink\Modules\User\Module',
'path' => APP_PATH.'/Modules/User/Module.php',
),
'admin' => array(
'className' => 'Xpatlink\Modules\Admin\Module',
'path' => APP_PATH.'/Modules/Admin/Module.php',
),
)
);
$request = new \Phalcon\Http\Request();
echo $application->handle($request->getURI())->getContent();
/*} catch (\Exception $e) {
echo $e->getMessage() . '<br>';
echo '<pre>' . $e->getTraceAsString() . '</pre>';
}*/
|