예제 #1
1
파일: DB.php 프로젝트: toshi-toshi/Tinitter
 /**
  * IlluminateのDB接続設定とブートアップ
  * @param array $settings 接続設定
  */
 public static function registerIlluminate(array $settings)
 {
     $capsule = new \Illuminate\Database\Capsule\Manager();
     $capsule->addConnection($settings);
     $capsule->setEventDispatcher(new \Illuminate\Events\Dispatcher(new \Illuminate\Container\Container()));
     $capsule->setAsGlobal();
     $capsule->bootEloquent();
 }
예제 #2
0
 public function setup()
 {
     $db = DbConfig::get_params();
     $capsule = new Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(['driver' => 'mysql', 'host' => $db['host'], 'database' => $db['dbname'], 'username' => $db['username'], 'password' => $db['password'], 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']);
     $capsule->setEventDispatcher(new Illuminate\Events\Dispatcher(new Illuminate\Container\Container()));
     $capsule->setAsGlobal();
     $capsule->bootEloquent();
 }
예제 #3
0
 public function getSlimInstance()
 {
     $capsule = new Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']);
     $capsule->setEventDispatcher(new Illuminate\Events\Dispatcher());
     $capsule->setAsGlobal();
     $capsule->bootEloquent();
     require __DIR__ . '/../app/schema.php';
     $app = new \Slim\Slim(['debug' => false, 'mode' => 'testing', 'templates.path' => __DIR__ . '/../views']);
     $app->setName('default');
     require __DIR__ . '/../app/app.php';
     return $app;
 }
예제 #4
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$capsule = new Illuminate\Database\Capsule\Manager();
$capsule->addConnection(require __DIR__ . '/config/database.php');
$capsule->setEventDispatcher(new Illuminate\Events\Dispatcher(new Illuminate\Container\Container()));
$capsule->bootEloquent();
$capsule->setAsGlobal();
$__autoload_paths = array('models', 'migrators', 'seeders');
foreach ($__autoload_paths as $path) {
    foreach (glob(__DIR__ . "/{$path}/*.php") as $dep) {
        require_once $dep;
    }
}
require __DIR__ . '/suite/CommentableTestCase.php';
예제 #5
0
<?php

$config = [];
$config['eloquentModelTemplate'] = function ($container) {
    return file_get_contents(realpath(__DIR__ . '/../templates') . '/ModelTemplate.txt');
};
$config['SlimApi\\Model\\ModelInterface'] = function ($container) {
    return new \SlimApi\Eloquent\Model\EloquentModelService($container->get('eloquentModelTemplate'), $container->get('namespace'));
};
$config['database.configForEloquent'] = function ($container) {
    $standardisedConfig = $container['database.config'];
    $eloquentConfig = ['driver' => $standardisedConfig['adapter'], 'host' => $standardisedConfig['host'], 'database' => $standardisedConfig['name'], 'username' => $standardisedConfig['user'], 'password' => $standardisedConfig['pass'], 'charset' => $standardisedConfig['charset'], 'collation' => 'utf8_unicode_ci', 'prefix' => ''];
    return $eloquentConfig;
};
$config['database.connectEloquent'] = function ($container) {
    $config = $container['database.configForEloquent'];
    $manager = new \Illuminate\Database\Capsule\Manager();
    $manager->addConnection($config);
    // Set the event dispatcher used by Eloquent models... (optional)
    $manager->setEventDispatcher(new \Illuminate\Events\Dispatcher(new \Illuminate\Container\Container()));
    // Make this Capsule instance available globally via static methods... (optional)
    $manager->setAsGlobal();
    // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
    $manager->bootEloquent();
    return $manager;
};
$config['SlimApi\\Eloquent\\Init'] = function ($container) {
    $container['database.connectEloquent'];
};
return $config;
예제 #6
0
<?php

include __DIR__ . '/vendor/autoload.php';
$capsule = new \Illuminate\Database\Capsule\Manager();
$capsule->addConnection(array('driver' => 'sqlite', 'database' => ':memory:'));
$capsule->setEventDispatcher(new \Illuminate\Events\Dispatcher());
$capsule->bootEloquent();
$capsule->setAsGlobal();
include __DIR__ . '/tests/models/Category.php';
예제 #7
0
});
$container->alias('Illuminate\\Session\\Store', 'session');
// Use the Sirius validation library for form validation
$container->singleton('App\\Components\\Validation\\FactoryInterface', function () {
    return new \App\Components\Validation\Sirius\SiriusValidatorFactory();
});
// Events component
$container->singleton('Illuminate\\Events\\Dispatcher', function ($container) {
    return new \Illuminate\Events\Dispatcher($container);
});
$container->alias('Illuminate\\Events\\Dispatcher', 'events');
// Database component
$capsule = new Illuminate\Database\Capsule\Manager();
$capsule->addConnection(['driver' => $config->get('database.driver'), 'host' => $config->get('database.host'), 'database' => $config->get('database.database'), 'username' => $config->get('database.username'), 'password' => $config->get('database.password'), 'charset' => $config->get('database.charset'), 'collation' => $config->get('database.collation'), 'prefix' => $config->get('database.prefix')]);
// Set the event dispatcher used by Eloquent models... (optional)
$capsule->setEventDispatcher($container->make('Illuminate\\Events\\Dispatcher'));
// Make this Capsule instance available globally via static methods... (optional)
$capsule->setAsGlobal();
// Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
$capsule->bootEloquent();
$container->instance('Illuminate\\Database\\Capsule\\Manager', $capsule);
$container->alias('Illuminate\\Database\\Capsule\\Manager', 'db');
// additional globally available components
/**
 * @var Slim\Slim
 */
$app = $container->make('app');
/**
 * @var App\Components\Routing\Router
 */
$router = $container->make('router');
예제 #8
0
 /**
  * 初始化数据库分发器
  * @function _initDefaultDbAdapter
  * @author   jsyzchenchen@gmail.com
  */
 public function _initDefaultDbAdapter()
 {
     //初始化 illuminate/database
     $capsule = new \Illuminate\Database\Capsule\Manager();
     $capsule->addConnection($this->config->database->toArray());
     $capsule->setEventDispatcher(new \Illuminate\Events\Dispatcher(new \Illuminate\Container\Container()));
     $capsule->setAsGlobal();
     //开启Eloquent ORM
     $capsule->bootEloquent();
     class_alias('\\Illuminate\\Database\\Capsule\\Manager', 'DB');
 }
예제 #9
0
파일: bootstrap.php 프로젝트: cruide/wasp
    $php_cfg = cfg('config')->php;
    if ($php_cfg->count() > 0) {
        foreach ($php_cfg->toArray() as $key => $val) {
            $key = str_replace('__', '.', $key);
            @ini_set($key, $val);
        }
        unset($key, $val);
    }
    unset($php_cfg);
}
unset($DisabledFunctions);
require CORE_PATH . DIR_SEP . 'smarty_security.php';
require CORE_LIBRARY_DIR . DIR_SEP . 'ui.php';
$config = cfg('dbase');
$events = new \Illuminate\Events\Dispatcher();
if ($config->count() > 0) {
    $database = new \Illuminate\Database\Capsule\Manager();
    foreach ($config->toArray() as $key => $val) {
        $database->addConnection(['driver' => 'mysql', 'host' => $val->host, 'database' => $val->database, 'username' => $val->username, 'password' => $val->password, 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => $val->prefix], strtolower($key));
    }
    $database->setAsGlobal();
    $database->bootEloquent();
    $database->setEventDispatcher($events);
    class_alias('\\Illuminate\\Database\\Capsule\\Manager', '\\Wasp\\DB');
    class_alias('\\Illuminate\\Database\\Schema\\Builder', '\\Wasp\\Schema');
    require CORE_LIBRARY_DIR . DIR_SEP . 'model.php';
    if (DEVELOP_MODE) {
        \Wasp\DB::enableQueryLog();
    }
}
app()->execute();
예제 #10
0
파일: connection.php 프로젝트: endel/hook
    $resolver->addConnection('app', $connection);
    $resolver->setDefaultConnection('default');
    DLModel::setConnectionResolver($resolver);
    DLModel::setEventDispatcher($event_dispatcher);
    $connection->setEventDispatcher($event_dispatcher);
} else {
    //
    // Create SQLite database
    //
    if ($db_config['driver'] == 'sqlite') {
        touch($db_config['database']);
    }
    $capsule = new Illuminate\Database\Capsule\Manager();
    $capsule->addConnection($db_config);
    $capsule->setFetchMode(PDO::FETCH_CLASS);
    $capsule->setEventDispatcher($event_dispatcher);
    $capsule->setAsGlobal();
    $capsule->bootEloquent();
    $connection = $capsule->connection();
    class_alias('\\Illuminate\\Database\\Eloquent\\Model', 'DLModel');
}
//
// Setup default date format
// Use a string representing an RFC2822 or ISO 8601 date
// http://tools.ietf.org/html/rfc2822#page-14
//
\Carbon\Carbon::setToStringFormat('Y-m-d\\TH:i:sP');
// Setup paginator
$connection->setPaginator(new Hook\Pagination\Environment());
// Setup Schema Grammar
// $connection->setSchemaGrammar();