Пример #1
0
<?php

use Dez\Config\Config;
use Dez\Db\Connection;
error_reporting(E_ALL);
ini_set('display_errors', 'On');
set_exception_handler(function (\Throwable $exception) {
    die('<b>' . get_class($exception) . '</b>: <i>' . $exception->getMessage() . '</b>' . "<pre>{$exception->getFile()}:{$exception->getLine()}</pre>");
});
include_once '../vendor/autoload.php';
$connectionConfig = Config::factory(__DIR__ . '/config.php');
$connectionName = $connectionConfig['db']->get('connection_name', 'development');
$db = new Connection($connectionConfig->path('db.connection')->get($connectionName));
///
$stmt = $db->query('select * from film');
var_dump($stmt->loadArray());
Пример #2
0
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'On');
use Dez\Config\Config;
include_once '../vendor/autoload.php';
$config = new Dez\Config\Adapter\NativeArray('./_config.php');
$configJson = new Dez\Config\Adapter\Json('./_config.json');
$config = Config::factory('./_config.ini')->merge($configJson);
die(var_dump($config->toArray(), $config->toIni(), $config->toJSON(), $config->toPHP()));
Пример #3
0
 /**
  * @return \Dez\Config\Adapter\Ini|\Dez\Config\Adapter\Json|\Dez\Config\Adapter\NativeArray|Config
  * @throws \Dez\Config\Exception
  */
 public static function sampleConfiguration()
 {
     $configurationFilePath = realpath(__DIR__ . '/../sample.configuration.php');
     $config = Config::factory($configurationFilePath);
     $config['sample_config_file'] = $configurationFilePath;
     return $config;
 }
Пример #4
0
<?php

namespace TestApp;

// composer autoload
use Dez\Config\Config;
use Dez\Mvc\Application\ConfigurableApplication;
use Dez\Mvc\Controller\RuntimeMvcException;
include_once '../vendor/autoload.php';
set_exception_handler(function (\Exception $exception) {
    die(get_class($exception) . ': ' . $exception->getMessage());
});
class TestApp extends ConfigurableApplication
{
    public function initialize()
    {
        return $this;
    }
    public function injection()
    {
        return $this;
    }
}
(new TestApp(Config::factory(__DIR__ . '/config/app.php')))->initialize()->injection()->configure()->run();
Пример #5
0
<?php

use Dez\Config\Config;
use Dez\DependencyInjection\Container;
use Dez\Http\Cookies;
use Dez\Http\Request;
use Dez\ORM\Connection as OrmConnection;
use Dez\Session\Adapter\Files;
include_once __DIR__ . '/../vendor/autoload.php';
error_reporting(E_ALL);
ini_set('display_errors', 'On');
$container = Container::instance();
$container->set('request', function () {
    return new Request();
});
$container->set('session', function () {
    return new Files();
});
$container->set('cookies', function () {
    return new Cookies();
});
OrmConnection::init(Config::factory(__DIR__ . '/config/connection.json'), 'dev');