Exemple #1
1
 public function setUp()
 {
     $capsule = new Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']);
     $capsule->setAsGlobal();
     $capsule->bootEloquent();
 }
Exemple #2
1
 /**
  * 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();
 }
Exemple #3
0
 public function setUp()
 {
     $capsule = new Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(['driver' => 'sqlite', 'database' => __DIR__ . '/database.sqlite']);
     $capsule->bootEloquent();
     $this->property = \Microsistec\DbParser\Models\Property::first();
 }
 private function boot()
 {
     // Connect to MySQL database
     $capsule = new \Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(array('driver' => 'mysql', 'host' => MYSQL_HOST, 'database' => MYSQL_DATABASE, 'username' => MYSQL_USERNAME, 'password' => MYSQL_PASSWORD, 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => ''));
     $capsule->bootEloquent();
 }
Exemple #5
0
 private static function loadOrm()
 {
     // Eloquent ORM
     $capsule = new \Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(require '../config/database.php');
     $capsule->bootEloquent();
 }
 /**
  * Run Method.
  *
  * Write your database seeder using this method.
  *
  * More information on writing seeders is available here:
  * http://docs.phinx.org/en/latest/seeding.html
  */
 public function run()
 {
     $capsule = new \Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(['driver' => 'sqlite', 'database' => __DIR__ . '/../../data/database.db']);
     $capsule->bootEloquent();
     \Cartalyst\Sentinel\Native\Facades\Sentinel::registerAndActivate(['email' => '*****@*****.**', 'password' => 'password']);
 }
Exemple #7
0
 /**
  * Init Core
  *
  * @uses Stativo\Helpers\Language
  * @uses Stativo\Helpers\File
  * @return \Core Returns instance of Stativo\Core\Core
  */
 public function init()
 {
     // Load env files
     $dotenv = new \Dotenv\Dotenv(DOCROOT, '.env');
     $dotenv->overload();
     // Load config (after \Dotenv)
     $config = self::config('app');
     // Init DB if is set true
     if ($config->get('database')['enabled']) {
         $capsule = new \Illuminate\Database\Capsule\Manager();
         foreach ($config->get('database')['connections'] as $name => $conn) {
             $capsule->addConnection($conn, $name);
         }
         $capsule->setAsGlobal();
         $capsule->bootEloquent();
     }
     // Init translation if set true
     if ($config->get('language')['enabled']) {
         \Stativo\Helpers\Language::instance();
     }
     if (class_exists(\Stativo\Helpers\File::class)) {
         \Stativo\Helpers\File::instance();
     }
     return $this;
 }
 public function _initEloquentORM()
 {
     Loader::import("vendor/autoload.php");
     $capsule = new \Illuminate\Database\Capsule\Manager();
     $capsule->addConnection($this->_config->orm->eloquent->toArray());
     $capsule->bootEloquent();
     $capsule->setAsGlobal();
 }
Exemple #9
0
function setupDB()
{
    $config = (include __DIR__ . '/../src/config.php');
    $capsule = new Illuminate\Database\Capsule\Manager();
    $connection = ['driver' => 'sqlite', 'database' => realpath(__DIR__ . '/' . $config['path'] . '/' . $config['db'])];
    $capsule->addConnection($connection, 'calibre');
    $capsule->setAsGlobal();
    $capsule->bootEloquent();
}
 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();
 }
Exemple #11
0
 function db()
 {
     $capsule = new Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(['driver' => 'mysql', 'host' => 'localhost', 'database' => 'Library', 'username' => 'root', 'password' => 'hornline', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']);
     // Make this Capsule instance available globally via static methods
     $capsule->setAsGlobal();
     // Setup the Eloquent ORM
     $capsule->bootEloquent();
 }
Exemple #12
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;
 }
Exemple #13
0
 public function register(\Exedra\Application $app)
 {
     $app->wizard->add(\Laraquent\Support\Exedra\Wizard::class);
     if (!$app->config->has('db')) {
         throw new \Exception('db. configuration is required.');
     }
     $config = $app->config;
     $capsule = new \Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(array('driver' => $config->get('db.driver', 'mysql'), 'host' => $config->get('db.host', 'localhost'), 'database' => $config->get('db.name'), 'username' => $config->get('db.user'), 'password' => $config->get('db.pass'), 'charset' => $config->get('db.charset', 'utf8'), 'collation' => $config->get('db.collation', 'utf8_unicode_ci')));
     $capsule->setAsGlobal();
     $capsule->bootEloquent();
     // register eloquent
     $app->eloquent = $capsule;
 }
Exemple #14
0
 public function __construct()
 {
     parent::__construct(['mode' => 'production']);
     // setup database connection
     $capsule = new \Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'resapi', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => ''));
     $capsule->setAsGlobal();
     $capsule->bootEloquent();
     // add middleware
     $this->add(new MiddlewareMediatype());
     $this->add(new MiddlewareAuthenticator());
     // add error message
     $this->notFound(function () {
         echo json_encode(['errmsg' => 'Not Found Request']);
     });
     Routing::setupRouting($this);
 }
 /**
  *
  */
 public function testIlluminateConnection()
 {
     Illuminate\Database\Capsule\Manager::schema()->create('test', function (Blueprint $table) {
         $table->increments('id');
         $table->string('email')->unique();
         $table->timestamps();
     });
     \Illuminate\Database\Capsule\Manager::table('test')->insert(['email' => '*****@*****.**']);
     $test = \Illuminate\Database\Capsule\Manager::table('test')->first();
     $this->assertNotEmpty($test);
     \Illuminate\Database\Capsule\Manager::schema()->drop('test');
 }
 public static function setUpBeforeClass()
 {
     $connection = [];
     switch (getenv('DB_ADAPTER')) {
         case 'sqlite':
             $connection['driver'] = 'sqlite';
             $connection['database'] = getenv('DB_NAME');
             break;
         case 'mysql':
             $connection['driver'] = 'mysql';
             $connection['host'] = getenv('DB_HOST');
             $connection['port'] = getenv('DB_PORT');
             $connection['database'] = getenv('DB_NAME');
             $connection['username'] = getenv('DB_USER');
             $connection['password'] = getenv('DB_PASS');
             $connection['charset'] = getenv('DB_CHARSET');
             $connection['collation'] = getenv('DB_COLLATION');
             break;
     }
     $capsule = new \Illuminate\Database\Capsule\Manager();
     $capsule->addConnection($connection);
     $capsule->setAsGlobal();
     $capsule->bootEloquent();
 }
Exemple #17
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('profiles', function ($table) {
    $table->increments('id');
    $table->integer('user_id')->unsigned()->unique();
    $table->string('nick')->nullable();
    $table->tinyInteger('sex')->default(0);
    $table->date('birthday')->nullable();
    $table->string('city')->nullable();
    $table->string('hobby')->nullable();
    $table->integer('rating')->default(0);
    $table->string('phone')->nullable();
    $table->string('url')->nullable();
    $table->text('custom_data')->nullable();
    $table->timestamps();
});
<?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';
Exemple #19
0
<?php

ini_set('error_reporting', E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
// Composer autoloader
require __DIR__ . '/../vendor/autoload.php';
// Boot Aspect Mock
$kernel = \AspectMock\Kernel::getInstance();
$src = __DIR__ . '/../src';
$eloquent = __DIR__ . '/../vendor/illuminate/database/Illuminate/Database/Eloquent';
$kernel->init(['debug' => true, 'cacheDir' => '/tmp/flexible', 'includePaths' => [$src, $eloquent]]);
// Boot the Eloquent component
$capsule = new \Illuminate\Database\Capsule\Manager();
$capsule->addConnection(array('driver' => 'sqlite', 'database' => __DIR__ . '/database/testing.sqlite', 'prefix' => ''));
$capsule->bootEloquent();
Exemple #20
0
<?php

$capsule = new \Illuminate\Database\Capsule\Manager();
$capsule->addConnection($app->getContainer()->get('settings')["database"]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
Exemple #21
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('user_providers', function ($table) {
    $table->increments('id');
    $table->string('user_id');
    $table->string('provider_name', 255);
    $table->string('provider_id', 255);
    $table->timestamps();
});
Exemple #22
0
<?php

// DIC configuration
$container = $app->getContainer();
// view renderer
$container['renderer'] = function ($c) {
    $settings = $c->get('settings')['renderer'];
    return new Slim\Views\PhpRenderer($settings['template_path']);
};
// monolog
$container['logger'] = function ($c) {
    $settings = $c->get('settings')['logger'];
    $logger = new Monolog\Logger($settings['name']);
    $logger->pushProcessor(new Monolog\Processor\UidProcessor());
    $logger->pushHandler(new Monolog\Handler\StreamHandler($settings['path'], Monolog\Logger::DEBUG));
    return $logger;
};
// database
$container['db'] = function ($c) {
    $settings = $c->get('database')['mysql'];
    $db = new \Illuminate\Database\Capsule\Manager();
    $db->addConnection($settings);
    $db->setAsGlobal();
    $db->bootEloquent();
    return $db;
};
Exemple #23
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('feedback_posts', function ($table) {
    $table->increments('id');
    $table->string('name', 100);
    $table->string('email');
    $table->text('message');
    $table->boolean('readed')->default(false);
    $table->boolean('closed')->default(false);
    $table->string('hash', 128);
    $table->integer('user_id')->unsigned()->default(0);
    $table->string('ip', 64)->default('127.0.0.1');
    // ipv6 & ipv4
    $table->timestamps();
});
Exemple #24
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('roles', function ($table) {
    $table->increments('id');
    $table->string('name');
    $table->text('permissions');
    $table->timestamps();
});
$now = date('Y-m-d H:i:s', time());
Illuminate\Database\Capsule\Manager::connection($connectName)->table('roles')->insert([['name' => 'OnlyRead', 'permissions' => '', 'created_at' => $now, 'updated_at' => $now], ['name' => 'User', 'permissions' => 'global/write;global/file', 'created_at' => $now, 'updated_at' => $now], ['name' => 'Moderator', 'permissions' => 'global/write;global/modify;global/file', 'created_at' => $now, 'updated_at' => $now], ['name' => 'Admin', 'permissions' => 'global/all', 'created_at' => $now, 'updated_at' => $now]]);
 /**
  * Compile Eloquent Queries
  *
  * @return	string
  */
 protected function _compile_eloquent()
 {
     $output = array();
     // hack to make eloquent not throw error for now
     $this->CI->load->model('eloquent/assets/action');
     if (!class_exists('Illuminate\\Database\\Capsule\\Manager')) {
         $output = 'Illuminate\\Database has not been loaded.';
     } else {
         // Load the text helper so we can highlight the SQL
         $this->CI->load->helper('text');
         // Key words we want bolded
         $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT&nbsp;JOIN', 'ORDER&nbsp;BY', 'GROUP&nbsp;BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR&nbsp;', 'HAVING', 'OFFSET', 'NOT&nbsp;IN', 'IN', 'LIKE', 'NOT&nbsp;LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')');
         $total = 0;
         // total query time
         $queries = Illuminate\Database\Capsule\Manager::getQueryLog();
         foreach ($queries as $q) {
             $time = number_format($q['time'] / 1000, 4);
             $total += $q['time'] / 1000;
             $query = interpolateQuery($q['query'], $q['bindings']);
             foreach ($highlight as $bold) {
                 $query = str_ireplace($bold, '<b>' . $bold . '</b>', $query);
             }
             $output[][$time] = $query;
         }
         if (count($output) == 0) {
             $output = $this->CI->lang->line('profiler_no_queries');
         } else {
             $total = number_format($total, 4);
             $output[][$total] = 'Total Query Execution Time';
         }
     }
     return $output;
 }
<?php

$container = $app->getContainer();
// Database
$container['capsule'] = function ($c) {
    $capsule = new Illuminate\Database\Capsule\Manager();
    $capsule->addConnection(['driver' => 'mysql', 'host' => getenv('DB_HOST'), 'database' => getenv('DB_DATABASE'), 'username' => getenv('DB_USERNAME'), 'password' => getenv('DB_PASSWORD'), 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => '']);
    return $capsule;
};
// Twig
$container['view'] = function ($c) {
    $view = new \Slim\Views\Twig('./resources/views');
    $view->addExtension(new \Slim\Views\TwigExtension($c['router'], $c['request']->getUri()));
    return $view;
};
<?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;
Exemple #28
0
 protected function boot()
 {
     $this->database->setAsGlobal();
     $this->database->bootEloquent();
 }
    $conn = PdoLite::dbConnect($settings['dsn'],$settings['username'],$settings['password']);
    */
    PdoLite::$cfg = $settings = $c->get('settings')['pdolite'];
    $conn = PdoLite::dbConnect($settings['dsn'], $settings['username'], $settings['password']);
    return $conn;
};
$container['pdo'] = function ($c) {
    $settings = $c->get('settings')['pdo'];
    print_r($settings);
    $conn = new PDO($settings['dsn'], $settings['username'], $settings['password']);
    echo "<br />Connect Info: ";
    print_r($conn);
    return $conn;
};
$container['capsule'] = function ($c) {
    $capsule = new Illuminate\Database\Capsule\Manager();
    $capsule->addConnection($c['settings']['db']);
    return $capsule;
};
// View
$container['view'] = function ($c) {
    $view = new \Slim\Views\Twig($c['settings']['view']['template_path'], $c['settings']['view']['twig']);
    // Add extensions
    //    echo "uri: ".$c['request']->getUri();
    $view->addExtension(new Slim\Views\TwigExtension($c['router'], $c['request']->getUri()));
    $view->addExtension(new Twig_Extension_Debug());
    //    $view->addExtension(new MVC4Slim\TwigExtension($c['flash']));
    $view->addExtension(new TwigExtension($c['flash']));
    return $view;
};
// CSRF guard
Exemple #30
0
<?php

/**
 * Access - Laravel 4 RBAC
 *
 * @author    Andreas Lutro <*****@*****.**>
 * @license   http://opensource.org/licenses/MIT
 * @package   anlutro/access
 */
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/TestCase.php';
foreach (glob(__DIR__ . '/../src/migrations/*.php') as $filename) {
    require_once $filename;
}
foreach (glob(__DIR__ . '/migrations/*.php') as $filename) {
    require_once $filename;
}
foreach (glob(__DIR__ . '/models/*.php') as $filename) {
    require_once $filename;
}
$capsule = new Illuminate\Database\Capsule\Manager();
$capsule->addConnection(['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']);
$capsule->setAsGlobal();
$capsule->bootEloquent();