Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jasonraimondi/af3342de1f4b05978615cc6c39afd872 to your computer and use it in GitHub Desktop.
Save jasonraimondi/af3342de1f4b05978615cc6c39afd872 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