私は構築しているカスタムPHPフレームワークでLaravelのEloquent ORMをコンポーザー経由で使用しようとしていますが、私のコントローラでcreateメソッドを呼び出すときに奇妙なエラーが発生します。Laravel Eloquent ORM - メソッド呼び出し時エラー
エラー:
Fatal error: Uncaught exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.' in /Users/justin/Sites/test/vendor/illuminate/container/Container.php:763 Stack trace: #0 /Users/justin/Sites/test/vendor/illuminate/container/Container.php(644): Illuminate\Container\Container->build('Illuminate\Cont...', Array) #1 /Users/justin/Sites/test/vendor/illuminate/database/Connectors/ConnectionFactory.php(130): Illuminate\Container\Container->make('Illuminate\Cont...') #2 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors{closure}() #3 /Users/justin/Sites/test/vendor/illuminate/database/Connection.php(964): call_user_func(Object(Closure)) #4 /Users/justin/Sites/test/vendor/illuminate/database/Connection.php(832): Illuminate\Database\Connection->getPdo() #5 /Users/justin/Sites/test/vendor/illuminate/database/Connection.php(717): Illuminate\Database\Connection->rec in /Users/justin/Sites/test/vendor/illuminate/container/Container.php on line 763
データベース接続:
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule();
$capsule->addConnection([
'driver' => 'mysql',
'host' => 'localhost',
'username' => 'root',
'password' => 'root',
'database' => 'database',
'port' => '3306',
'charset' => 'utf-8',
'collation' => 'utf8_unicode_ci'
]);
$capsule->bootEloquent();
モデル:
use Illuminate\Database\Eloquent\Model as Eloquent;
class User extends Eloquent{
protected $fillable = ['username','email'];
}
最後方法:
public function create($username = '', $email = ''){
User::create([
'username' => $username,
'email' => $email
]);
}
誰かが私を助けることはできますか?
「明るくする/データベース」:「^ 5.3」「 '' ' –