Skip to content

Instantly share code, notes, and snippets.

@dgoguerra
Created July 15, 2016 10:15
Show Gist options
  • Save dgoguerra/5857b9312413474b8117c7031e4c8bc7 to your computer and use it in GitHub Desktop.
Save dgoguerra/5857b9312413474b8117c7031e4c8bc7 to your computer and use it in GitHub Desktop.
Minimal code to load a Laravel application
<?php
require_once __DIR__.'/vendor/autoload.php';
function bootstrapApplication()
{
$app = require __DIR__.'/vendor/laravel/laravel/bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
$app['config']['database.default'] = 'mysql';
$app['config']['database.connections.mysql.database'] = 'test_db';
$app['config']['database.connections.mysql.username'] = 'test_app';
$app['config']['database.connections.mysql.password'] = 'secret';
return $app;
}
$app = bootstrapApplication();
// load service providers
$app->register('App\Providers\CustomServiceProvider');
// edit the app's settings
$app['config']['app.debug'] = true;
// obtain a class from the Service Container
$service = $app['App\Services\CustomService'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment