/home
/u4663
/2019.ooo-strit.ru
/vendor
/phact-cmf
/phact
/src
/Phact
/Application
/Application.php
public function handleWebRequest()
{
/** @var HttpRequestInterface $request */
$request = $this->getComponent(HttpRequestInterface::class);
/** @var RouterInterface $router */
$router = $this->getComponent(RouterInterface::class);
$url = $request->getUrl();
$method = $request->getMethod();
$this->logDebug("Matching route for url '{$url}' and method '{$method}'");
$matches = $router->match($url, $method);
foreach ($matches as $match) {
$matched = $this->handleMatch($match, $router);
if ($matched !== false) {
return true;
}
}
$this->logDebug("Matching route not found");
throw new NotFoundHttpException("Page not found");
}
public function handleMatch(array $match, RouterInterface $router = null)
{
if (is_array($match['target']) &&
isset($match['target'][0]) &&
is_a($match['target'][0], ControllerInterface::class, true))
{
$controllerClass = $match['target'][0];
$action = isset($match['target'][1]) ? $match['target'][1] : null;
$params = isset($match['params']) ? $match['params'] : [];
$name = isset($match['name']) ? $match['name'] : null;
if ($router && $name) {
$router->setCurrentName($name);
}
$this->logDebug("Processing route to controller '{$controllerClass}' and action '{$action}'", ['params' => $params]);
/** @var Controller $controller */
$controller = $this->_container->construct($controllerClass);
/home
/u4663
/2019.ooo-strit.ru
/vendor
/phact-cmf
/phact
/src
/Phact
/Application
/Application.php
$this->logDebug("Application run");
$this->eventTrigger("application.beforeRun", [], $this);
$this->provideModuleEvent('onApplicationRun');
register_shutdown_function([$this, 'end'], 0);
$this->logDebug("Start handling request");
$this->handleRequest();
$this->end();
}
public function end($status = 0, $response = null)
{
$this->eventTrigger("application.beforeEnd", [], $this);
$this->provideModuleEvent('onApplicationEnd', [$status, $response]);
exit($status);
}
public function handleRequest()
{
if ($this->getIsWebMode()) {
$this->handleWebRequest();
} else {
$this->handleCliRequest();
}
}
/**
* @return bool
*/
public static function getIsCliMode()
{
return php_sapi_name() == 'cli';
}
/**
* @return bool
*/
public static function getIsWebMode()
{
return !self::getIsCliMode();
}
/home
/u4663
/2019.ooo-strit.ru
/vendor
/phact-cmf
/phact
/src
/Phact
/Application
/Application.php
throw new InvalidConfigException('Runtime path must be a valid and writable directory. Please, set up correct runtime path in "paths" section of configuration.');
}
$modulesPath = $paths->get('Modules');
if (!$modulesPath && ($modulesPath = $paths->get('base.Modules')) && is_dir($modulesPath)) {
$paths->add('Modules', $modulesPath);
}
if (!is_dir($modulesPath)) {
throw new InvalidConfigException('Modules path must be a valid. Please, set up correct modules path in "paths" section of configuration.');
}
}
}
public function run()
{
$this->logDebug("Application run");
$this->eventTrigger("application.beforeRun", [], $this);
$this->provideModuleEvent('onApplicationRun');
register_shutdown_function([$this, 'end'], 0);
$this->logDebug("Start handling request");
$this->handleRequest();
$this->end();
}
public function end($status = 0, $response = null)
{
$this->eventTrigger("application.beforeEnd", [], $this);
$this->provideModuleEvent('onApplicationEnd', [$status, $response]);
exit($status);
}
public function handleRequest()
{
if ($this->getIsWebMode()) {
$this->handleWebRequest();
} else {
$this->handleCliRequest();
}
}
/**
/home
/u4663
/2019.ooo-strit.ru
/WWW
/index.php
<?php
include(__DIR__ . '/../vendor/autoload.php');
$configPath = __DIR__ . '/../app/config/settings.php';
$localConfigPath = __DIR__ . '/../app/config/local_settings.php';
$debug = true;
if (is_file($localConfigPath)) {
$configPath = $localConfigPath;
$debug = true;
}
define("PHACT_DEBUG", $debug);
$config = include $configPath;
\Phact\Main\Phact::init($config);
\Phact\Main\Phact::app()->run();