サブシステムには Illuminate (Non Eloquent) を使用する必要があります。データベース用に 1000 以上のモデルを作成したくありません。
Query メソッドを動作させることができますが、Builder
.
app.php
use \Illuminate\Database\Capsule\Manager as Capsule;
use \Illuminate\Database\Query\Builder;
use \SuperClosure\SerializableClosure;
use \Pimple\Container;
$container = new Container();
$container['db'] = new SerializableClosure(function() use ($database_config) {
print_r($database_config);
$capsule = new Capsule;
$capsule->addConnection([
'driver' => $database_config['driver'],
'host' => $database_config['host'],
'database' => $database_config['database'],
'username' => $database_config['username'],
'password' => $database_config['password'],
'charset' => $database_config['charset'],
'collation' => $database_config['collation'],
]);
$capsule->setFetchMode(\PDO::FETCH_OBJ);
// Re-use the connection if needed
$connection = $capsule->getConnection();
// I want to Attach this so I can have access in one DI call.
$capsule->builder = new Builder($connection);
return $connection;
});
エラー
ビルダーを追加しようとしたときにのみ、次のエラーが発生します。
PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message
'Unsupported driver []' in
(...) /vendor/illuminate/database/Connectors/ConnectionFactory.php:226
ドキュメントでは、__construct() には接続が必要ですがGrammar
、Processors
オブジェクトも必要です。これらは必要ですか?
クロージャの $database_config
$database_config =
(
[driver] => mysql
[host] => localhost
[database] => project
[username] => root
[password] =>
[charset] => utf8
[collation] => utf8_unicode_ci
)
composer.json
"illuminate/database": "^5.2",
"illuminate/pagination": "^5.2",
"illuminate/events": "^5.2",
"illuminate/console": "^5.2",