Created
August 16, 2017 11:21
-
-
Save FoggyK/d54c18a05ec5ee10d1bdc98ad03d2231 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Zend\Mvc\Application; | |
use Zend\Stdlib\ArrayUtils; | |
/** | |
* Это облегчает нам работу с путями. | |
* Все пути теперь - относительно корня приложения. | |
*/ | |
chdir(dirname(__DIR__)); | |
// Отклонить запросы статического файла | |
if (php_sapi_name() === 'cli-server') { | |
$path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); | |
if (__FILE__ !== $path && is_file($path)) { | |
return false; | |
} | |
unset($path); | |
} | |
// Автозагрузка Composer | |
include __DIR__ . '/../vendor/autoload.php'; | |
if (! class_exists(Application::class)) { | |
throw new RuntimeException( | |
"Unable to load application.\n" | |
. "- Type `composer install` if you are developing locally.\n" | |
. "- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.\n" | |
. "- Type `docker-compose run zf composer install` if you are using Docker.\n" | |
); | |
} | |
// Извлечение конфигурации | |
$appConfig = require __DIR__ . '/../config/application.config.php'; | |
if (file_exists(__DIR__ . '/../config/development.config.php')) { | |
$appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php'); | |
} | |
// Запуск приложения! | |
Application::init($appConfig)->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment