Guest User

Untitled

a guest
May 2nd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. require_once __DIR__ . '/../bootstrap/init.php';
  2.  
  3. $app_name = getenv('APP_NAME');
  4.  
  5.  
  6. use IlluminateDatabaseCapsuleManager as Capsule;
  7.  
  8. $user = Capsule::table('users')->where('id', 1)->first();
  9.  
  10. APP_ENV = local
  11.  
  12. APP_NAME = "ACME E-commerce store"
  13.  
  14. #database
  15.  
  16. DB_DRIVER=mysql
  17.  
  18. DB_HOST=localhost
  19.  
  20. DB_NAME=store
  21.  
  22. DB_USERNAME=store
  23.  
  24. DB_PASSWORD=secret
  25.  
  26. public function __construct()
  27. {
  28. $db = new Capsule;
  29. $db->addConnection([
  30. 'driver' => getenv('DB_DRIVER'),
  31. 'host' => getenv('DB_HOST'),
  32. 'database' => getenv('DB_NAME'),
  33. 'username' => getenv('DB_USERNAME'),
  34. 'password' => getenv('DB_PASSWORD'),
  35. 'charset' => 'utf8',
  36. 'collation' => 'utf8_unicode_ci',
  37. 'prefix' => ' '
  38.  
  39. ]);
  40.  
  41. $db->setAsGlobal();
  42. $db->bootEloquent();
  43. }
Add Comment
Please, Sign In to add comment