Exemple #1
0
 /**
  * @inheritdoc
  */
 public function initializeClasses(SymfonyRequest $symfonyRequest)
 {
     Utf8\Bootup::initAll();
     // Enables the portability layer and configures PHP for UTF-8
     Utf8\Bootup::filterRequestUri();
     // Redirects to an UTF-8 encoded URL if it's not already the case
     Utf8\Bootup::filterRequestInputs();
     // Normalizes HTTP inputs to UTF-8 NFC
     $file = $this->appPath->getCacheDir() . 'container.php';
     $this->dumpContainer($symfonyRequest, $file);
     require_once $file;
     $this->container = new \ACP3ServiceContainer();
     $this->container->set('core.environment.application_path', $this->appPath);
     $this->container->set('core.http.symfony_request', $symfonyRequest);
 }
Exemple #2
0
 /**
  * Application constructor.
  *
  * @param object $loader The autoloader instance.
  * @param array $config The custom configuration of the application.
  * @param string $appPath The application absolute path.
  * @param array $classesMap The custom classes map of the application.
  */
 public function __construct($loader, array $config = [], $appPath = null, array $classesMap = [])
 {
     # Utilities
     $this->utilities = new Utilities($this);
     # Register start time
     $this->utilities->registerStartTime();
     # Store application path
     $this->utilities->setApplicationPath($appPath);
     # Store classes map
     $this['class'] = $this->utilities->setClassesMap($classesMap);
     # Call container constructor
     parent::__construct($this->utilities->setConfiguration($config));
     # Register core services providers
     $this->register(new FilesystemServiceProvider());
     $this->register(new FinderServiceProvider());
     $this->register(new HttpServiceProvider());
     $this->register(new LoggerServiceProvider());
     $this->register(new MessagesServiceProvider());
     $this->register(new RouterServiceProvider());
     $this->register(new SupportServiceProvider());
     $this->register(new TemplatingServiceProvider());
     $this->register(new TriggersServiceProvider());
     # Enables the portablity layer and configures PHP for UTF-8
     Utf8Bootup::initAll();
     # Redirects to an UTF-8 encoded URL if it's not already the case
     Utf8Bootup::filterRequestUri();
     # Normalizes HTTP inputs to UTF-8 NFC
     Utf8Bootup::filterRequestInputs();
     # Print errors in debug mode
     if ($this['debug']) {
         $whoops = new WhoopsRun();
         $whoops->pushHandler(new WhoopsHandler());
         $whoops->register();
     } else {
         ErrorHandler::register($this['phpLogger']);
     }
     # Only enable Kint in debug mode
     \Kint::enabled($this['debug']);
 }
Exemple #3
0
    date_default_timezone_set(@date_default_timezone_get());
}
// Emulate PHP 5.4 feature that allows us to create/use an object without a temporary.
// PHP 5.4: (new X)->y()
// PHP 5.3: with(new X)->y()
function with($x)
{
    return $x;
}
// Use the patchwork/utf8 library to:
// 1) set all PHP defaults to UTF-8
// 2) create shims for missing mb_string functions such as mb_strlen()
// 3) check that requests are valid UTF-8
\Patchwork\Utf8\Bootup::initAll();
// Enables the portablity layer and configures PHP for UTF-8
\Patchwork\Utf8\Bootup::filterRequestUri();
// Redirects to an UTF-8 encoded URL if it's not already the case
\Patchwork\Utf8\Bootup::filterRequestInputs();
// Normalizes HTTP inputs to UTF-8 NFC
// Use the fisharebest/ext-calendar library to
// 1) provide shims for the PHP ext/calendar extension, such as JewishToJD()
// 2) provide calendar conversions for the Arabic and Persian calendars
\Fisharebest\ExtCalendar\Shim::create();
// Split the request protocol://host:port/path/to/script.php?var=value into parts
// WT_SERVER_NAME  = protocol://host:port
// WT_SCRIPT_PATH  = /path/to/   (begins and ends with /)
// WT_SCRIPT_NAME  = script.php  (already defined in the calling script)
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off';
define('WT_SERVER_NAME', ($https ? 'https://' : 'http://') . (empty($_SERVER['SERVER_NAME']) ? '' : $_SERVER['SERVER_NAME']) . (empty($_SERVER['SERVER_PORT']) || !$https && $_SERVER['SERVER_PORT'] == 80 || $https && $_SERVER['SERVER_PORT'] == 443 ? '' : ':' . $_SERVER['SERVER_PORT']));
// REDIRECT_URL should be set in the case of Apache following a RedirectRule
// SCRIPT_NAME should always be correct, but is not always present.