Skip to content

Instantly share code, notes, and snippets.

@jlem
Created August 21, 2015 14:35
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save jlem/086b9b408e454dc0bd34 to your computer and use it in GitHub Desktop.
Save jlem/086b9b408e454dc0bd34 to your computer and use it in GitHub Desktop.
Laravel 5 App Skeleton
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Request;
use View;
use App;
abstract class ApplicationsServiceProvider extends ServiceProvider
{
public function register()
{
$this->registerApp();
}
public function boot()
{
$this->setViewNamespace();
$this->includeRoutes();
$this->bootApp();
}
private function setViewNamespace()
{
View::addNamespace($this->viewNamespace, $this->getPath('views'));
}
private function includeRoutes()
{
require $this->getPath('routes.php');
}
private function getPath($endpoint)
{
return base_path("apps/{$this->application}/{$endpoint}");
}
abstract protected function registerApp();
abstract protected function bootApp();
}
<?php namespace Apps\ExampleApp;
use App\Providers\AppsServiceProvider;
use App;
// Dont forget to register this with config/app.php
class ExampleAppServiceProvider extends AppsServiceProvider
{
public $application = 'ExampleApp';
public $viewNamespace = 'example';
protected function registerApp()
{
}
protected function bootApp()
{
}
}
app/
apps/ <--- new folder. Put your "app bundles" here, PSR-4 it as Apps
ExampleApp/
Controllers/
Middleware/
Requests/
views/
ExampleAppServiceProvider.php
routes.php
bootstrap/
config/
..etc../
<?php
Route::group([
'prefix' => 'example'
'namespace' => 'Apps\ExampleApp\Controllers'
], function() {
Route::get('whatever', 'FooController@bar');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment