capsule_orm.php 766 B

123456789101112131415161718192021222324252627
  1. <?php
  2. use Illuminate\Database\Capsule\Manager as Capsule;
  3. $capsule = new Capsule;
  4. $capsule->addConnection([
  5. 'driver' => 'mysql',
  6. 'host' => 'localhost',
  7. 'database' => 'database',
  8. 'username' => 'root',
  9. 'password' => 'password',
  10. 'charset' => 'utf8',
  11. 'collation' => 'utf8_unicode_ci',
  12. 'prefix' => '',
  13. ]);
  14. // Set the event dispatcher used by Eloquent models... (optional)
  15. use Illuminate\Events\Dispatcher;
  16. use Illuminate\Container\Container;
  17. $capsule->setEventDispatcher(new Dispatcher(new Container));
  18. // Make this Capsule instance available globally via static methods... (optional)
  19. $capsule->setAsGlobal();
  20. // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
  21. $capsule->bootEloquent();