Created
August 21, 2015 14:35
-
-
Save jlem/086b9b408e454dc0bd34 to your computer and use it in GitHub Desktop.
Laravel 5 App Skeleton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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() | |
{ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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