Example #1
0
 /**
  * Get the SessionHandler. When no session handler has been defined,
  * create one.
  *
  * @return SessionHandler
  */
 private function getSessionObject()
 {
     if ($this->sessionObject === null) {
         $sessionHandler = \Application::getConfig()->get('Session');
         if ($sessionHandler === null) {
             $this->sessionObject = new SessionHandlers\Session();
         } else {
             $config = isset($sessionHandler['Config']) && is_array($sessionHandler['Config']) ? $sessionHandler['Config'] : [];
             $class = isset($sessionHandler['Handler']) ? (string) $sessionHandler['Handler'] : 'Framework\\Web\\SessionHandlers\\Session';
             $class = class_exists($class) ? $class : (class_exists('Framework\\Web\\SessionHandlers\\' . $class) ? 'Framework\\Web\\SessionHandlers\\' . $class : 'Framework\\Web\\SessionHandlers\\Session');
             $this->sessionObject = new $class($config);
         }
     }
     return $this->sessionObject;
 }
Example #2
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
use Framework\Web\Application as WebApplication;
use Framework\Console\Application as ConsoleApplication;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\EventDispatcher\EventDispatcher;
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(__DIR__));
$loader->load(__DIR__ . '/src/config/services.xml');
$container->setParameter('document_root', __DIR__);
$container->compile();
if (php_sapi_name() == 'cli') {
    $app = new ConsoleApplication($container);
} else {
    $app = new WebApplication($container, new EventDispatcher());
}
$app->run();