Skip to content

Instantly share code, notes, and snippets.

@0xMatt
Created January 15, 2015 20:56
Show Gist options
  • Save 0xMatt/1448b59bca70963166b4 to your computer and use it in GitHub Desktop.
Save 0xMatt/1448b59bca70963166b4 to your computer and use it in GitHub Desktop.
RouteServiceProvider
<?php
namespace Lithe\Routing;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
*
* @var boolean
*/
protected $scanWhenLocal = true;
/**
*/
public function map()
{
if ($this->scanWhenLocal && $this->app->environment('local') || ! file_Exists(app_path('Http/routes.php'))) {
$this->scan();
}
$this->load();
}
/**
*/
protected function scan()
{
$scanner = new Scanner($this->app['modules'], $this->app['Modules\System\Domain\Page\PageRepository']);
file_put_contents(app_path('Http/routes.php'), '<?php ' . $scanner->definitions());
}
/**
*/
protected function load()
{
if (file_exists(storage_path('framework') . '/routes.php')) {
return;
}
require_once app_path('Http/routes.php');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment