diff --git a/.gitignore b/.gitignore index 145ed6b6c01..14b5a330802 100644 --- a/.gitignore +++ b/.gitignore @@ -173,6 +173,9 @@ samples/client/petstore/python-asyncio/.venv/ samples/client/petstore/python-asyncio/.pytest_cache/ samples/client/petstore/python-tornado/.venv/ +# PHP +samples/server/petstore/php-lumen/lib/composer.lock + # ts samples/client/petstore/typescript-angular2/npm/npm-debug.log samples/client/petstore/typescript-node/npm/npm-debug.log diff --git a/bin/configs/php-lumen.yaml b/bin/configs/php-lumen.yaml index b8c82bc52d0..4436f9ba46d 100644 --- a/bin/configs/php-lumen.yaml +++ b/bin/configs/php-lumen.yaml @@ -1,4 +1,4 @@ generatorName: php-lumen outputDir: samples/server/petstore/php-lumen -inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml templateDir: modules/openapi-generator/src/main/resources/php-lumen diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLumenServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLumenServerCodegen.java index e5ef7bba34c..14dc0768185 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLumenServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLumenServerCodegen.java @@ -105,6 +105,18 @@ public class PhpLumenServerCodegen extends AbstractPhpCodegen { * are available in models, apis, and supporting files */ additionalProperties.put("apiVersion", apiVersion); + } + + @Override + public void processOpts() { + super.processOpts(); + + // reset supporting files defined in AbstractPhpCodegen + supportingFiles.clear(); + + // AbstractPhpCodegen generates .gitignore in output folder + // current build needs .gitignore in a "lib" folder which is srcBasePath + supportingFiles.add(new SupportingFile("gitignore", srcBasePath, ".gitignore")); /* * Supporting Files. You can write single files for the generator with the @@ -112,7 +124,11 @@ public class PhpLumenServerCodegen extends AbstractPhpCodegen { * it will be processed by the template engine. Otherwise, it will be copied */ supportingFiles.add(new SupportingFile(".env.example", srcBasePath, ".env.example")); - supportingFiles.add(new SupportingFile("storage_logs_.gitignore", srcBasePath + File.separator + "storage" + File.separator + "logs", ".gitignore")); + supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "logs", ".gitignore")); + supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "app", ".gitignore")); + supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "framework" + File.separator + "views", ".gitignore")); + supportingFiles.add(new SupportingFile("storage_framework_cache_gitignore", srcBasePath + File.separator + "storage" + File.separator + "framework" + File.separator + "cache", ".gitignore")); + supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "framework" + File.separator + "cache" + File.separator + "data", ".gitignore")); supportingFiles.add(new SupportingFile("artisan", srcBasePath, "artisan")); supportingFiles.add(new SupportingFile("composer.mustache", srcBasePath, "composer.json")); supportingFiles.add(new SupportingFile("readme.md", srcBasePath, "readme.md")); @@ -142,6 +158,9 @@ public class PhpLumenServerCodegen extends AbstractPhpCodegen { supportingFiles.add(new SupportingFile("routes.mustache", srcBasePath + File.separator + "routes", "web.php")); supportingFiles.add(new SupportingFile("ExampleTest.php", srcBasePath + File.separator + "tests", "ExampleTest.php")); supportingFiles.add(new SupportingFile("TestCase.php", srcBasePath + File.separator + "tests", "TestCase.php")); + supportingFiles.add(new SupportingFile("editorconfig", srcBasePath, ".editorconfig")); + supportingFiles.add(new SupportingFile("styleci", srcBasePath, ".styleci.yml")); + supportingFiles.add(new SupportingFile("phpunit.xml", srcBasePath, "phpunit.xml")); } // override with any special post-processing diff --git a/modules/openapi-generator/src/main/resources/php-lumen/.env.example b/modules/openapi-generator/src/main/resources/php-lumen/.env.example index 9e27ce13c48..77194452c5b 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/.env.example +++ b/modules/openapi-generator/src/main/resources/php-lumen/.env.example @@ -1,6 +1,8 @@ +APP_NAME=Lumen APP_ENV=local -APP_DEBUG=true APP_KEY= +APP_DEBUG=true +APP_URL=http://localhost APP_TIMEZONE=UTC LOG_CHANNEL=stack @@ -14,4 +16,4 @@ DB_USERNAME=homestead DB_PASSWORD=secret CACHE_DRIVER=file -QUEUE_DRIVER=sync \ No newline at end of file +QUEUE_CONNECTION=sync diff --git a/modules/openapi-generator/src/main/resources/php-lumen/AppServiceProvider.php b/modules/openapi-generator/src/main/resources/php-lumen/AppServiceProvider.php index ddec04694c3..50c43897809 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/AppServiceProvider.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/AppServiceProvider.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Providers; use Illuminate\Support\ServiceProvider; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/AuthServiceProvider.php b/modules/openapi-generator/src/main/resources/php-lumen/AuthServiceProvider.php index 9502a0bfce7..e9bdb2eb578 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/AuthServiceProvider.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/AuthServiceProvider.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Providers; use App\User; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/Authenticate.php b/modules/openapi-generator/src/main/resources/php-lumen/Authenticate.php index 7cd3d5829a2..7be121ca61c 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Authenticate.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Authenticate.php @@ -1,11 +1,6 @@ licenseInfoLumen}} namespace App\Http\Middleware; use Closure; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/Controller.php b/modules/openapi-generator/src/main/resources/php-lumen/Controller.php index 8c3690dc789..027132d26a9 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Controller.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Controller.php @@ -1,11 +1,6 @@ licenseInfoLumen}} namespace App\Http\Controllers; use Laravel\Lumen\Routing\Controller as BaseController; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/DatabaseSeeder.php b/modules/openapi-generator/src/main/resources/php-lumen/DatabaseSeeder.php index 23526c9d99c..e6d0dee0356 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/DatabaseSeeder.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/DatabaseSeeder.php @@ -1,5 +1,6 @@ licenseInfoLumen}} use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder diff --git a/modules/openapi-generator/src/main/resources/php-lumen/Event.php b/modules/openapi-generator/src/main/resources/php-lumen/Event.php index b8230f0fff1..ad07b2c2415 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Event.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Event.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Events; use Illuminate\Queue\SerializesModels; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/EventServiceProvider.php b/modules/openapi-generator/src/main/resources/php-lumen/EventServiceProvider.php index a3d284fc29f..57f198622cb 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/EventServiceProvider.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/EventServiceProvider.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Providers; use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider; @@ -12,8 +13,8 @@ class EventServiceProvider extends ServiceProvider * @var array */ protected $listen = [ - 'App\Events\ExampleEvent' => [ - 'App\Listeners\ExampleListener', + \App\Events\ExampleEvent::class => [ + \App\Listeners\ExampleListener::class, ], ]; } diff --git a/modules/openapi-generator/src/main/resources/php-lumen/ExampleController.php b/modules/openapi-generator/src/main/resources/php-lumen/ExampleController.php index aab066e8c7d..81d1ff5190e 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/ExampleController.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/ExampleController.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Http\Controllers; class ExampleController extends Controller diff --git a/modules/openapi-generator/src/main/resources/php-lumen/ExampleEvent.php b/modules/openapi-generator/src/main/resources/php-lumen/ExampleEvent.php index 4bd12685bd2..cd3d462ebba 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/ExampleEvent.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/ExampleEvent.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Events; class ExampleEvent extends Event diff --git a/modules/openapi-generator/src/main/resources/php-lumen/ExampleJob.php b/modules/openapi-generator/src/main/resources/php-lumen/ExampleJob.php index 7b65bb42288..4ad285c71b4 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/ExampleJob.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/ExampleJob.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Jobs; class ExampleJob extends Job diff --git a/modules/openapi-generator/src/main/resources/php-lumen/ExampleListener.php b/modules/openapi-generator/src/main/resources/php-lumen/ExampleListener.php index 77fc6a85f90..93822950d78 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/ExampleListener.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/ExampleListener.php @@ -1,10 +1,11 @@ licenseInfoLumen}} namespace App\Listeners; use App\Events\ExampleEvent; -use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; class ExampleListener { @@ -21,7 +22,7 @@ class ExampleListener /** * Handle the event. * - * @param ExampleEvent $event + * @param \App\Events\ExampleEvent $event * @return void */ public function handle(ExampleEvent $event) diff --git a/modules/openapi-generator/src/main/resources/php-lumen/ExampleMiddleware.php b/modules/openapi-generator/src/main/resources/php-lumen/ExampleMiddleware.php index 166581c8e69..6d54e9f9918 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/ExampleMiddleware.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/ExampleMiddleware.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Http\Middleware; use Closure; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/ExampleTest.php b/modules/openapi-generator/src/main/resources/php-lumen/ExampleTest.php index 1bad6ef7ed7..d258feaad33 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/ExampleTest.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/ExampleTest.php @@ -1,5 +1,6 @@ licenseInfoLumen}} use Laravel\Lumen\Testing\DatabaseMigrations; use Laravel\Lumen\Testing\DatabaseTransactions; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/Handler.php b/modules/openapi-generator/src/main/resources/php-lumen/Handler.php index 56f3a44603c..af1f860e323 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Handler.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Handler.php @@ -1,19 +1,14 @@ licenseInfoLumen}} namespace App\Exceptions; -use Exception; -use Illuminate\Validation\ValidationException; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Database\Eloquent\ModelNotFoundException; -use Symfony\Component\HttpKernel\Exception\HttpException; +use Illuminate\Validation\ValidationException; use Laravel\Lumen\Exceptions\Handler as ExceptionHandler; +use Symfony\Component\HttpKernel\Exception\HttpException; +use Throwable; class Handler extends ExceptionHandler { @@ -34,23 +29,27 @@ class Handler extends ExceptionHandler * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * - * @param \Exception $e + * @param \Throwable $exception * @return void + * + * @throws \Exception */ - public function report(Exception $e) + public function report(Throwable $exception) { - parent::report($e); + parent::report($exception); } /** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request - * @param \Exception $e - * @return \Illuminate\Http\Response + * @param \Throwable $exception + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse + * + * @throws \Throwable */ - public function render($request, Exception $e) + public function render($request, Throwable $exception) { - return parent::render($request, $e); + return parent::render($request, $exception); } } diff --git a/modules/openapi-generator/src/main/resources/php-lumen/Job.php b/modules/openapi-generator/src/main/resources/php-lumen/Job.php index 7c873e10bdf..7c71ea4e7de 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Job.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Job.php @@ -1,11 +1,12 @@ licenseInfoLumen}} namespace App\Jobs; use Illuminate\Bus\Queueable; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; abstract class Job implements ShouldQueue { diff --git a/modules/openapi-generator/src/main/resources/php-lumen/Kernel.php b/modules/openapi-generator/src/main/resources/php-lumen/Kernel.php index ed6d21b681e..a651f3a30d5 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Kernel.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Kernel.php @@ -1,11 +1,6 @@ licenseInfoLumen}} namespace App\Console; use Illuminate\Console\Scheduling\Schedule; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/ModelFactory.php b/modules/openapi-generator/src/main/resources/php-lumen/ModelFactory.php index bf9496b0eef..b1ab1efde7c 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/ModelFactory.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/ModelFactory.php @@ -1,17 +1,23 @@ licenseInfoLumen}} +/** @var \Illuminate\Database\Eloquent\Factory $factory */ + +use App\User; +use Faker\Generator as Faker; + /* |-------------------------------------------------------------------------- | Model Factories |-------------------------------------------------------------------------- | -| Here you may define all of your model factories. Model factories give -| you a convenient way to create models for testing and seeding your -| database. Just tell the factory how a default model should look. +| This directory should contain each of the model factory definitions for +| your application. Factories provide a convenient way to generate new +| model instances for testing / seeding your application's database. | */ -$factory->define(App\User::class, function (Faker\Generator $faker) { +$factory->define(User::class, function (Faker $faker) { return [ 'name' => $faker->name, 'email' => $faker->email, diff --git a/modules/openapi-generator/src/main/resources/php-lumen/TestCase.php b/modules/openapi-generator/src/main/resources/php-lumen/TestCase.php index 89a058d1210..7e40485e841 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/TestCase.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/TestCase.php @@ -1,6 +1,9 @@ licenseInfoLumen}} +use Laravel\Lumen\Testing\TestCase as BaseTestCase; + +abstract class TestCase extends BaseTestCase { /** * Creates the application. diff --git a/modules/openapi-generator/src/main/resources/php-lumen/User.php b/modules/openapi-generator/src/main/resources/php-lumen/User.php index 94adde8542e..41f9806a2a1 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/User.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/User.php @@ -1,22 +1,15 @@ licenseInfoLumen}} namespace App; use Illuminate\Auth\Authenticatable; -use Laravel\Lumen\Auth\Authorizable; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; +use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; +use Illuminate\Database\Eloquent\Model; +use Laravel\Lumen\Auth\Authorizable; -class User extends Model implements - AuthenticatableContract, - AuthorizableContract +class User extends Model implements AuthenticatableContract, AuthorizableContract { use Authenticatable, Authorizable; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/app.php b/modules/openapi-generator/src/main/resources/php-lumen/app.php index 58dc9d942b9..1a1d5bb493c 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/app.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/app.php @@ -1,18 +1,13 @@ licenseInfoLumen}} require_once __DIR__.'/../vendor/autoload.php'; -try { - (new Dotenv\Dotenv(__DIR__.'/../'))->load(); -} catch (Dotenv\Exception\InvalidPathException $e) { - // -} +(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables( + dirname(__DIR__) +))->bootstrap(); + +date_default_timezone_set(env('APP_TIMEZONE', 'UTC')); /* |-------------------------------------------------------------------------- @@ -26,7 +21,7 @@ try { */ $app = new Laravel\Lumen\Application( - realpath(__DIR__.'/../') + dirname(__DIR__) ); // $app->withFacades(); @@ -54,6 +49,19 @@ $app->singleton( App\Console\Kernel::class ); +/* +|-------------------------------------------------------------------------- +| Register Config Files +|-------------------------------------------------------------------------- +| +| Now we will register the "app" configuration file. If the file exists in +| your configuration directory it will be loaded; otherwise, we'll load +| the default version. You may register other files below as needed. +| +*/ + +$app->configure('app'); + /* |-------------------------------------------------------------------------- | Register Middleware @@ -66,7 +74,7 @@ $app->singleton( */ // $app->middleware([ -// App\Http\Middleware\ExampleMiddleware::class +// App\Http\Middleware\ExampleMiddleware::class // ]); // $app->routeMiddleware([ @@ -105,6 +113,4 @@ $app->router->group([ require __DIR__.'/../routes/web.php'; }); -$app->withFacades(); - return $app; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/artisan b/modules/openapi-generator/src/main/resources/php-lumen/artisan index 6a9d095aeae..46fb1b6f90e 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/artisan +++ b/modules/openapi-generator/src/main/resources/php-lumen/artisan @@ -1,6 +1,7 @@ #!/usr/bin/env php licenseInfoLumen}} use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Output\ConsoleOutput; diff --git a/modules/openapi-generator/src/main/resources/php-lumen/composer.mustache b/modules/openapi-generator/src/main/resources/php-lumen/composer.mustache index 433cfd18ad5..27bef59bba6 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/composer.mustache +++ b/modules/openapi-generator/src/main/resources/php-lumen/composer.mustache @@ -24,29 +24,26 @@ ], "type": "project", "require": { - "php": ">=7.1.3", - "laravel/lumen-framework": "5.6.*", - "vlucas/phpdotenv": "~2.2" + "php": "^7.2.5", + "laravel/lumen-framework": "^7.2" }, "require-dev": { - "fzaninotto/faker": "~1.4", - "phpunit/phpunit": "~7.0", - "mockery/mockery": "~1.0" + "fzaninotto/faker": "^1.9", + "mockery/mockery": "^1.3", + "phpunit/phpunit": "^8.0 || ^9.0" }, "autoload": { + "classmap": [ + "database/seeds", + "database/factories" + ], "psr-4": { "App\\": "app/" } }, "autoload-dev": { "classmap": [ - "tests/", - "database/" - ] - }, - "scripts": { - "post-root-package-install": [ - "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" + "tests/" ] }, "config": { @@ -55,5 +52,10 @@ "optimize-autoloader": true }, "minimum-stability": "dev", - "prefer-stable": true + "prefer-stable": true, + "scripts": { + "post-root-package-install": [ + "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" + ] + } } diff --git a/modules/openapi-generator/src/main/resources/php-lumen/editorconfig b/modules/openapi-generator/src/main/resources/php-lumen/editorconfig new file mode 100644 index 00000000000..6537ca4677e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/php-lumen/editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 diff --git a/modules/openapi-generator/src/main/resources/php-lumen/gitignore b/modules/openapi-generator/src/main/resources/php-lumen/gitignore index 390a8878ede..2896e8647b2 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/gitignore +++ b/modules/openapi-generator/src/main/resources/php-lumen/gitignore @@ -1,8 +1,6 @@ -# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore - -composer.phar -/vendor/ - -# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control -# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -# composer.lock \ No newline at end of file +/vendor +/.idea +Homestead.json +Homestead.yaml +.env +.phpunit.result.cache diff --git a/modules/openapi-generator/src/main/resources/php-lumen/index.php b/modules/openapi-generator/src/main/resources/php-lumen/index.php index 7f44de3e275..add2c7c0755 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/index.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/index.php @@ -1,11 +1,6 @@ licenseInfoLumen}} /* |-------------------------------------------------------------------------- | Create The Application diff --git a/modules/openapi-generator/src/main/resources/php-lumen/licenseInfo.mustache b/modules/openapi-generator/src/main/resources/php-lumen/licenseInfo.mustache index ef8396ce24d..b119e2a8b97 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/licenseInfo.mustache +++ b/modules/openapi-generator/src/main/resources/php-lumen/licenseInfo.mustache @@ -1,7 +1,7 @@ /** * {{{appName}}} * {{{appDescription}}} - * PHP version 7.1.3 + * PHP version 7.2.5 * * {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}} * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} diff --git a/modules/openapi-generator/src/main/resources/php-lumen/licenseInfoLumen.mustache b/modules/openapi-generator/src/main/resources/php-lumen/licenseInfoLumen.mustache new file mode 100644 index 00000000000..52855d2fdd0 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/php-lumen/licenseInfoLumen.mustache @@ -0,0 +1,3 @@ +/** + * The Lumen framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). + */ diff --git a/modules/openapi-generator/src/main/resources/php-lumen/phpunit.xml b/modules/openapi-generator/src/main/resources/php-lumen/phpunit.xml index 218bbb4b49b..e94653dc912 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/phpunit.xml +++ b/modules/openapi-generator/src/main/resources/php-lumen/phpunit.xml @@ -1,14 +1,8 @@ - + ./tests @@ -20,9 +14,8 @@ - - + diff --git a/modules/openapi-generator/src/main/resources/php-lumen/readme.md b/modules/openapi-generator/src/main/resources/php-lumen/readme.md index 77316595b80..b13967538b1 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/readme.md +++ b/modules/openapi-generator/src/main/resources/php-lumen/readme.md @@ -1,7 +1,7 @@ # OpenAPITools generated server ## Requirements -* PHP 7.1.3 or newer +* PHP 7.2.5 or newer ## Overview This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the @@ -18,9 +18,15 @@ This example uses the [Lumen Framework](http://lumen.laravel.com/). To see how Switch to the generated Lumen server stub directory. Using `composer update` to install the framework and dependencies via [Composer](http://getcomposer.org/). +### Init App Config +Use `.env.example` as starting point for a new application config: +```console +$ composer run post-root-package-install +``` + ## Note -The `composer update` should be the first thing to do right after generating Lumen server stub. The autoload.php will be generated only after excuting `composer update`. +The `composer update` should be the first thing to do right after generating Lumen server stub. The autoload.php will be generated only after executing `composer update`. Or there would be errors during service or model migration. ### Running the generated server stub diff --git a/modules/openapi-generator/src/main/resources/php-lumen/routes.mustache b/modules/openapi-generator/src/main/resources/php-lumen/routes.mustache index 0f0c9d92f00..9eed65e61b8 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/routes.mustache +++ b/modules/openapi-generator/src/main/resources/php-lumen/routes.mustache @@ -1,11 +1,23 @@ licenseInfo}} +{{>licenseInfoLumen}} {{#apiInfo}}/** * {{appName}} * @version {{appVersion}} */ +/* +|-------------------------------------------------------------------------- +| 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. +| +*/ + $router->get('/', function () use ($router) { return $router->app->version(); }); @@ -19,8 +31,8 @@ $router->get('/', function () use ($router) { * Notes: {{notes}} */ $router->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', '{{classname}}@{{operationId}}'); + {{/operation}} {{/operations}} {{/apis}} {{/apiInfo}} - diff --git a/modules/openapi-generator/src/main/resources/php-lumen/storage_framework_cache_gitignore b/modules/openapi-generator/src/main/resources/php-lumen/storage_framework_cache_gitignore new file mode 100644 index 00000000000..01e4a6cda9e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/php-lumen/storage_framework_cache_gitignore @@ -0,0 +1,3 @@ +* +!data/ +!.gitignore diff --git a/modules/openapi-generator/src/main/resources/php-lumen/storage_logs_.gitignore b/modules/openapi-generator/src/main/resources/php-lumen/storage_logs_.gitignore deleted file mode 100644 index c96a04f008e..00000000000 --- a/modules/openapi-generator/src/main/resources/php-lumen/storage_logs_.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/php-lumen/storage_logs_gitignore b/modules/openapi-generator/src/main/resources/php-lumen/storage_logs_gitignore new file mode 100644 index 00000000000..d6b7ef32c84 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/php-lumen/storage_logs_gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/modules/openapi-generator/src/main/resources/php-lumen/styleci b/modules/openapi-generator/src/main/resources/php-lumen/styleci new file mode 100644 index 00000000000..89801211440 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/php-lumen/styleci @@ -0,0 +1,6 @@ +php: + preset: laravel + disabled: + - unused_use +js: true +css: true diff --git a/pom.xml b/pom.xml index d4fdeae7fe5..0b77ce578f6 100644 --- a/pom.xml +++ b/pom.xml @@ -1182,6 +1182,7 @@ samples/server/petstore/python-flask samples/server/petstore/php-slim4 samples/server/petstore/php-laravel + samples/server/petstore/php-lumen samples/server/petstore/rust-server