add support for lumen 5.3.x

This commit is contained in:
Amine Ben hammou 2017-01-18 14:18:58 +00:00
parent 93856362b7
commit 55fcf27362
2 changed files with 41 additions and 4 deletions

View File

@ -59,3 +59,36 @@ $app->get("/", function () use ($app) {
return $app->welcome(); return $app->welcome();
}); });
'); ');
$I->wantTo('run wn:routes in Lumen 5.3+');
mkdir('./routes');
$I->writeToFile('./routes/web.php', '<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$app->get("/", function () use ($app) {
return $app->version();
});
');
$I->runShellCommand('php artisan wn:route foo --controller=customController');
$I->seeInShellOutput('foo routes generated');
$I->openFile('./routes/web.php');
$I->seeInThisFile("
\$app->get('foo', 'customController@all');
\$app->get('foo/{id}', 'customController@get');
\$app->post('foo', 'customController@add');
\$app->put('foo/{id}', 'customController@put');
\$app->delete('foo/{id}', 'customController@remove');
");
$I->deleteDir('./routes');

View File

@ -13,7 +13,11 @@ class RouteCommand extends BaseCommand {
{ {
$resource = $this->argument('resource'); $resource = $this->argument('resource');
$content = $this->fs->get('./app/Http/routes.php'); $routesPath = './routes/web.php';
if (! $this->fs->exists($routesPath))
$routesPath = './app/Http/routes.php';
$content = $this->fs->get($routesPath);
$content .= PHP_EOL . $this->getTemplate('routes') $content .= PHP_EOL . $this->getTemplate('routes')
->with([ ->with([
@ -22,7 +26,7 @@ class RouteCommand extends BaseCommand {
]) ])
->get(); ->get();
$this->save($content, './app/Http/routes.php', "{$resource} routes", true); $this->save($content, $routesPath, "{$resource} routes", true);
} }
protected function getController() protected function getController()