From 04d293d7fad3a0bc2ad42abb05592578495f2f50 Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Sun, 14 Jun 2020 01:09:42 +0300 Subject: [PATCH 01/12] Set required PHP version to ^7.2.5 --- .../src/main/resources/php-lumen/composer.mustache | 2 +- .../src/main/resources/php-lumen/licenseInfo.mustache | 2 +- .../openapi-generator/src/main/resources/php-lumen/readme.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 433cfd18ad51..e8d63c2f7ec2 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/composer.mustache +++ b/modules/openapi-generator/src/main/resources/php-lumen/composer.mustache @@ -24,7 +24,7 @@ ], "type": "project", "require": { - "php": ">=7.1.3", + "php": "^7.2.5", "laravel/lumen-framework": "5.6.*", "vlucas/phpdotenv": "~2.2" }, 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 ef8396ce24d4..b119e2a8b97a 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/readme.md b/modules/openapi-generator/src/main/resources/php-lumen/readme.md index 77316595b804..e1a288ee9d3f 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 From edd13be12b1ca952371ac7213973886848451223 Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Sun, 14 Jun 2020 02:17:04 +0300 Subject: [PATCH 02/12] Write .gitignore into srcBasePath --- .../codegen/languages/PhpLumenServerCodegen.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 e5ef7bba34cc..30d2df264f20 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 PhpLumenServerCodegen() { * 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 From 3f31e1d159177dd32e0ef5a1ffd99e447170c248 Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Sun, 14 Jun 2020 12:29:04 +0300 Subject: [PATCH 03/12] Update dependencies --- .../src/main/resources/php-lumen/composer.mustache | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 e8d63c2f7ec2..41e1ee5f863d 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/composer.mustache +++ b/modules/openapi-generator/src/main/resources/php-lumen/composer.mustache @@ -25,13 +25,12 @@ "type": "project", "require": { "php": "^7.2.5", - "laravel/lumen-framework": "5.6.*", - "vlucas/phpdotenv": "~2.2" + "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": { "psr-4": { From d5a4b5e427c992044930da2984747be77cacd7e4 Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 15 Jul 2020 19:19:51 +0300 Subject: [PATCH 04/12] Copy latest Lumen sources to templates --- .../languages/PhpLumenServerCodegen.java | 9 ++++- .../src/main/resources/php-lumen/.env.example | 6 ++-- .../main/resources/php-lumen/Authenticate.php | 6 ---- .../main/resources/php-lumen/Controller.php | 6 ---- .../php-lumen/EventServiceProvider.php | 4 +-- .../resources/php-lumen/ExampleListener.php | 4 +-- .../src/main/resources/php-lumen/Handler.php | 30 ++++++++-------- .../src/main/resources/php-lumen/Job.php | 4 +-- .../src/main/resources/php-lumen/Kernel.php | 6 ---- .../main/resources/php-lumen/ModelFactory.php | 13 ++++--- .../src/main/resources/php-lumen/TestCase.php | 4 ++- .../src/main/resources/php-lumen/User.php | 16 +++------ .../src/main/resources/php-lumen/app.php | 35 +++++++++++-------- .../resources/php-lumen/composer.mustache | 19 +++++----- .../src/main/resources/php-lumen/editorconfig | 15 ++++++++ .../src/main/resources/php-lumen/gitignore | 14 ++++---- .../src/main/resources/php-lumen/index.php | 6 ---- .../src/main/resources/php-lumen/phpunit.xml | 17 +++------ .../main/resources/php-lumen/routes.mustache | 13 ++++++- .../storage_framework_cache_gitignore | 3 ++ .../php-lumen/storage_logs_.gitignore | 2 -- .../php-lumen/storage_logs_gitignore | 2 ++ .../src/main/resources/php-lumen/styleci | 6 ++++ 23 files changed, 128 insertions(+), 112 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/php-lumen/editorconfig create mode 100644 modules/openapi-generator/src/main/resources/php-lumen/storage_framework_cache_gitignore delete mode 100644 modules/openapi-generator/src/main/resources/php-lumen/storage_logs_.gitignore create mode 100644 modules/openapi-generator/src/main/resources/php-lumen/storage_logs_gitignore create mode 100644 modules/openapi-generator/src/main/resources/php-lumen/styleci 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 30d2df264f20..14dc0768185f 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 @@ -124,7 +124,11 @@ public void processOpts() { * 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")); @@ -154,6 +158,9 @@ public void processOpts() { 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 9e27ce13c484..77194452c5b3 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/Authenticate.php b/modules/openapi-generator/src/main/resources/php-lumen/Authenticate.php index 7cd3d5829a2f..361a11eecd00 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,5 @@ [ - 'App\Listeners\ExampleListener', + \App\Events\ExampleEvent::class => [ + \App\Listeners\ExampleListener::class, ], ]; } 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 77fc6a85f90b..a4fe5f31db79 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/ExampleListener.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/ExampleListener.php @@ -3,8 +3,8 @@ namespace App\Listeners; use App\Events\ExampleEvent; -use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; class ExampleListener { @@ -21,7 +21,7 @@ public function __construct() /** * 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/Handler.php b/modules/openapi-generator/src/main/resources/php-lumen/Handler.php index 56f3a44603c4..b375c61abb58 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,13 @@ 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 89a058d12105..136846b1a621 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,8 @@ load(); -} catch (Dotenv\Exception\InvalidPathException $e) { - // -} +(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables( + dirname(__DIR__) +))->bootstrap(); + +date_default_timezone_set(env('APP_TIMEZONE', 'UTC')); /* |-------------------------------------------------------------------------- @@ -26,7 +20,7 @@ */ $app = new Laravel\Lumen\Application( - realpath(__DIR__.'/../') + dirname(__DIR__) ); // $app->withFacades(); @@ -54,6 +48,19 @@ 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 +73,7 @@ */ // $app->middleware([ -// App\Http\Middleware\ExampleMiddleware::class +// App\Http\Middleware\ExampleMiddleware::class // ]); // $app->routeMiddleware([ @@ -105,6 +112,4 @@ require __DIR__.'/../routes/web.php'; }); -$app->withFacades(); - return $app; 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 41e1ee5f863d..27bef59bba66 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/composer.mustache +++ b/modules/openapi-generator/src/main/resources/php-lumen/composer.mustache @@ -33,19 +33,17 @@ "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": { @@ -54,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 000000000000..6537ca4677ee --- /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 390a8878ede4..2896e8647b29 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 7f44de3e275d..04aa08688e00 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,5 @@ - + ./tests @@ -20,9 +14,8 @@ - - + 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 0f0c9d92f009..304751409cda 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/routes.mustache +++ b/modules/openapi-generator/src/main/resources/php-lumen/routes.mustache @@ -6,6 +6,17 @@ * @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 +30,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 000000000000..01e4a6cda9eb --- /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 c96a04f008ee..000000000000 --- 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 000000000000..d6b7ef32c847 --- /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 000000000000..89801211440a --- /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 From 22206428c1fd94bad684f7e7076ec894287c5b7b Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 15 Jul 2020 17:31:39 +0300 Subject: [PATCH 05/12] Add Lumen license template --- .../src/main/resources/php-lumen/licenseInfoLumen.mustache | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 modules/openapi-generator/src/main/resources/php-lumen/licenseInfoLumen.mustache 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 000000000000..52855d2fdd01 --- /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). + */ From 357fad9dd8f9beb5d5cabf911760ab3a8149637b Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 15 Jul 2020 20:09:11 +0300 Subject: [PATCH 06/12] Use Lumen license in templates --- .../src/main/resources/php-lumen/AppServiceProvider.php | 1 + .../src/main/resources/php-lumen/AuthServiceProvider.php | 1 + .../src/main/resources/php-lumen/Authenticate.php | 1 + .../src/main/resources/php-lumen/Controller.php | 1 + .../src/main/resources/php-lumen/DatabaseSeeder.php | 1 + modules/openapi-generator/src/main/resources/php-lumen/Event.php | 1 + .../src/main/resources/php-lumen/EventServiceProvider.php | 1 + .../src/main/resources/php-lumen/ExampleController.php | 1 + .../src/main/resources/php-lumen/ExampleEvent.php | 1 + .../src/main/resources/php-lumen/ExampleJob.php | 1 + .../src/main/resources/php-lumen/ExampleListener.php | 1 + .../src/main/resources/php-lumen/ExampleMiddleware.php | 1 + .../src/main/resources/php-lumen/ExampleTest.php | 1 + .../openapi-generator/src/main/resources/php-lumen/Handler.php | 1 + modules/openapi-generator/src/main/resources/php-lumen/Job.php | 1 + .../openapi-generator/src/main/resources/php-lumen/Kernel.php | 1 + .../src/main/resources/php-lumen/ModelFactory.php | 1 + .../openapi-generator/src/main/resources/php-lumen/TestCase.php | 1 + modules/openapi-generator/src/main/resources/php-lumen/User.php | 1 + modules/openapi-generator/src/main/resources/php-lumen/app.php | 1 + modules/openapi-generator/src/main/resources/php-lumen/artisan | 1 + modules/openapi-generator/src/main/resources/php-lumen/index.php | 1 + .../src/main/resources/php-lumen/routes.mustache | 1 + 23 files changed, 23 insertions(+) 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 ddec04694c37..50c438978093 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 9502a0bfce79..e9bdb2eb578a 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 361a11eecd00..7be121ca61c9 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Authenticate.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Authenticate.php @@ -1,5 +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 0ccb91866c68..027132d26a99 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Controller.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Controller.php @@ -1,5 +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 23526c9d99ce..e6d0dee03561 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 b8230f0fff18..ad07b2c24154 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 6830e6080396..57f198622cb0 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; 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 aab066e8c7d7..81d1ff5190e9 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 4bd12685bd26..cd3d462ebbac 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 7b65bb42288c..4ad285c71b49 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 a4fe5f31db79..93822950d783 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/ExampleListener.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/ExampleListener.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Listeners; use App\Events\ExampleEvent; 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 166581c8e69b..6d54e9f9918f 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 1bad6ef7ed7d..d258feaad33d 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 b375c61abb58..af1f860e3234 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Handler.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Handler.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Exceptions; use Illuminate\Auth\Access\AuthorizationException; 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 38988dbcee82..7c71ea4e7dea 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Job.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Job.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App\Jobs; use Illuminate\Bus\Queueable; 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 ad6e311cdd04..a651f3a30d5c 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/Kernel.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/Kernel.php @@ -1,5 +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 953a6a13024c..b1ab1efde7c3 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/ModelFactory.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/ModelFactory.php @@ -1,5 +1,6 @@ licenseInfoLumen}} /** @var \Illuminate\Database\Eloquent\Factory $factory */ use App\User; 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 136846b1a621..7e40485e841b 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/TestCase.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/TestCase.php @@ -1,5 +1,6 @@ licenseInfoLumen}} use Laravel\Lumen\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase 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 0284e3d59dbf..41f9806a2a1b 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/User.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/User.php @@ -1,5 +1,6 @@ licenseInfoLumen}} namespace App; use Illuminate\Auth\Authenticatable; 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 b3df6ee8318d..1a1d5bb493c7 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/app.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/app.php @@ -1,5 +1,6 @@ licenseInfoLumen}} require_once __DIR__.'/../vendor/autoload.php'; (new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables( diff --git a/modules/openapi-generator/src/main/resources/php-lumen/artisan b/modules/openapi-generator/src/main/resources/php-lumen/artisan index 6a9d095aeae0..46fb1b6f90ec 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/index.php b/modules/openapi-generator/src/main/resources/php-lumen/index.php index 04aa08688e00..add2c7c07556 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/index.php +++ b/modules/openapi-generator/src/main/resources/php-lumen/index.php @@ -1,5 +1,6 @@ licenseInfoLumen}} /* |-------------------------------------------------------------------------- | Create The Application 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 304751409cda..9eed65e61b8f 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/routes.mustache +++ b/modules/openapi-generator/src/main/resources/php-lumen/routes.mustache @@ -1,6 +1,7 @@ licenseInfo}} +{{>licenseInfoLumen}} {{#apiInfo}}/** * {{appName}} * @version {{appVersion}} From 2b574db7b64f1b13da40adbb618bb7932968c18b Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 15 Jul 2020 19:39:45 +0300 Subject: [PATCH 07/12] Fix typo in readme --- .../openapi-generator/src/main/resources/php-lumen/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e1a288ee9d3f..4db55b9d7bc2 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/readme.md +++ b/modules/openapi-generator/src/main/resources/php-lumen/readme.md @@ -20,7 +20,7 @@ Using `composer update` to install the framework and dependencies via [Composer] ## 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 From 6cc1136f4d3b8a7208312d523833a41a8f61b1ef Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 15 Jul 2020 19:44:25 +0300 Subject: [PATCH 08/12] Add Init App Config readme section --- .../src/main/resources/php-lumen/readme.md | 6 ++++++ 1 file changed, 6 insertions(+) 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 4db55b9d7bc2..b13967538b1f 100644 --- a/modules/openapi-generator/src/main/resources/php-lumen/readme.md +++ b/modules/openapi-generator/src/main/resources/php-lumen/readme.md @@ -18,6 +18,12 @@ 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 executing `composer update`. From c7e6b242ad208a4855d6fb33981a591261e402cb Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 15 Jul 2020 19:21:07 +0300 Subject: [PATCH 09/12] Add composer.lock to root gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 4739673eb889..4f880001de10 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 From f4904868db0a6cd0149d7d5f107875429ddf5e5f Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 15 Jul 2020 19:51:48 +0300 Subject: [PATCH 10/12] Add Travis-CI task --- pom.xml | 1 + samples/server/petstore/php-lumen/pom.xml | 74 +++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 samples/server/petstore/php-lumen/pom.xml diff --git a/pom.xml b/pom.xml index dc7ebf7a3ba1..fd55ae0e0850 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 samples/client/petstore/perl diff --git a/samples/server/petstore/php-lumen/pom.xml b/samples/server/petstore/php-lumen/pom.xml new file mode 100644 index 000000000000..e546eb7e4d12 --- /dev/null +++ b/samples/server/petstore/php-lumen/pom.xml @@ -0,0 +1,74 @@ + + 4.0.0 + org.openapitools + LumenPetstoreServerTests + pom + 1.0-SNAPSHOT + Lumen Petstore Server + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + bundle-install + pre-integration-test + + exec + + + composer + + install + --working-dir=lib + + + + + bundle-copy-config + pre-integration-test + + exec + + + cp + + lib/.env.example + lib/.env + + + + + bundle-test + integration-test + + exec + + + lib/vendor/bin/phpunit + + --configuration=lib/phpunit.xml + + + + + + + + From ea7032666ad690f999bf1fcf1157aa6c8fbf3b30 Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 15 Jul 2020 19:56:07 +0300 Subject: [PATCH 11/12] Set OAS 3.0 input spec file for samples --- bin/configs/php-lumen.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/configs/php-lumen.yaml b/bin/configs/php-lumen.yaml index b8c82bc52d04..4436f9ba46d4 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 From 087085bb87db00f52196df11f5b352a4892ef3bd Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 15 Jul 2020 20:49:14 +0300 Subject: [PATCH 12/12] Refresh samples --- samples/server/petstore/php-lumen/.gitignore | 8 -- .../php-lumen/.openapi-generator/FILES | 10 ++- .../petstore/php-lumen/lib/.editorconfig | 15 ++++ .../petstore/php-lumen/lib/.env.example | 6 +- .../server/petstore/php-lumen/lib/.gitignore | 6 ++ .../petstore/php-lumen/lib/.styleci.yml | 6 ++ .../php-lumen/lib/app/Console/Kernel.php | 4 +- .../php-lumen/lib/app/Events/Event.php | 4 + .../php-lumen/lib/app/Events/ExampleEvent.php | 4 + .../php-lumen/lib/app/Exceptions/Handler.php | 28 ++++--- .../app/Http/Controllers/AnotherFakeApi.php | 8 +- .../lib/app/Http/Controllers/Controller.php | 4 +- .../lib/app/Http/Controllers/DefaultApi.php | 3 +- .../Http/Controllers/ExampleController.php | 4 + .../lib/app/Http/Controllers/FakeApi.php | 67 ++++++++++------ .../Controllers/FakeClassnameTags123Api.php | 8 +- .../lib/app/Http/Controllers/PetApi.php | 14 ++-- .../lib/app/Http/Controllers/StoreApi.php | 8 +- .../lib/app/Http/Controllers/UserApi.php | 20 ++--- .../lib/app/Http/Middleware/Authenticate.php | 6 +- .../app/Http/Middleware/ExampleMiddleware.php | 4 + .../php-lumen/lib/app/Jobs/ExampleJob.php | 4 + .../petstore/php-lumen/lib/app/Jobs/Job.php | 8 +- .../lib/app/Listeners/ExampleListener.php | 8 +- .../lib/app/Providers/AppServiceProvider.php | 4 + .../lib/app/Providers/AuthServiceProvider.php | 4 + .../app/Providers/EventServiceProvider.php | 8 +- .../petstore/php-lumen/lib/app/User.php | 14 ++-- samples/server/petstore/php-lumen/lib/artisan | 4 + .../petstore/php-lumen/lib/bootstrap/app.php | 33 +++++--- .../petstore/php-lumen/lib/composer.json | 30 +++---- .../lib/database/factories/ModelFactory.php | 17 +++- .../lib/database/seeds/DatabaseSeeder.php | 4 + .../server/petstore/php-lumen/lib/phpunit.xml | 21 +++++ .../petstore/php-lumen/lib/public/index.php | 4 +- .../server/petstore/php-lumen/lib/readme.md | 10 ++- .../petstore/php-lumen/lib/routes/web.php | 79 +++++++++++++++++-- .../php-lumen/lib/storage/app/.gitignore | 2 + .../lib/storage/framework/cache/.gitignore | 3 + .../storage/framework/cache/data/.gitignore | 2 + .../lib/storage/framework/views/.gitignore | 2 + .../php-lumen/lib/storage/logs/.gitignore | 2 +- .../php-lumen/lib/tests/ExampleTest.php | 4 + .../petstore/php-lumen/lib/tests/TestCase.php | 8 +- 44 files changed, 367 insertions(+), 145 deletions(-) delete mode 100644 samples/server/petstore/php-lumen/.gitignore create mode 100644 samples/server/petstore/php-lumen/lib/.editorconfig create mode 100644 samples/server/petstore/php-lumen/lib/.gitignore create mode 100644 samples/server/petstore/php-lumen/lib/.styleci.yml create mode 100644 samples/server/petstore/php-lumen/lib/phpunit.xml create mode 100644 samples/server/petstore/php-lumen/lib/storage/app/.gitignore create mode 100644 samples/server/petstore/php-lumen/lib/storage/framework/cache/.gitignore create mode 100644 samples/server/petstore/php-lumen/lib/storage/framework/cache/data/.gitignore create mode 100644 samples/server/petstore/php-lumen/lib/storage/framework/views/.gitignore diff --git a/samples/server/petstore/php-lumen/.gitignore b/samples/server/petstore/php-lumen/.gitignore deleted file mode 100644 index 390a8878ede4..000000000000 --- a/samples/server/petstore/php-lumen/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# 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 diff --git a/samples/server/petstore/php-lumen/.openapi-generator/FILES b/samples/server/petstore/php-lumen/.openapi-generator/FILES index dbcc669ec26c..b432c662dc47 100644 --- a/samples/server/petstore/php-lumen/.openapi-generator/FILES +++ b/samples/server/petstore/php-lumen/.openapi-generator/FILES @@ -1,5 +1,7 @@ -.gitignore +lib/.editorconfig lib/.env.example +lib/.gitignore +lib/.styleci.yml lib/app/Console/Commands/.gitkeep lib/app/Console/Kernel.php lib/app/Events/Event.php @@ -7,6 +9,7 @@ lib/app/Events/ExampleEvent.php lib/app/Exceptions/Handler.php lib/app/Http/Controllers/AnotherFakeApi.php lib/app/Http/Controllers/Controller.php +lib/app/Http/Controllers/DefaultApi.php lib/app/Http/Controllers/ExampleController.php lib/app/Http/Controllers/FakeApi.php lib/app/Http/Controllers/FakeClassnameTags123Api.php @@ -28,11 +31,16 @@ lib/composer.json lib/database/factories/ModelFactory.php lib/database/migrations/.gitkeep lib/database/seeds/DatabaseSeeder.php +lib/phpunit.xml lib/public/.htaccess lib/public/index.php lib/readme.md lib/resources/views/.gitkeep lib/routes/web.php +lib/storage/app/.gitignore +lib/storage/framework/cache/.gitignore +lib/storage/framework/cache/data/.gitignore +lib/storage/framework/views/.gitignore lib/storage/logs/.gitignore lib/tests/ExampleTest.php lib/tests/TestCase.php diff --git a/samples/server/petstore/php-lumen/lib/.editorconfig b/samples/server/petstore/php-lumen/lib/.editorconfig new file mode 100644 index 000000000000..6537ca4677ee --- /dev/null +++ b/samples/server/petstore/php-lumen/lib/.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/samples/server/petstore/php-lumen/lib/.env.example b/samples/server/petstore/php-lumen/lib/.env.example index 9e27ce13c484..77194452c5b3 100644 --- a/samples/server/petstore/php-lumen/lib/.env.example +++ b/samples/server/petstore/php-lumen/lib/.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/samples/server/petstore/php-lumen/lib/.gitignore b/samples/server/petstore/php-lumen/lib/.gitignore new file mode 100644 index 000000000000..2896e8647b29 --- /dev/null +++ b/samples/server/petstore/php-lumen/lib/.gitignore @@ -0,0 +1,6 @@ +/vendor +/.idea +Homestead.json +Homestead.yaml +.env +.phpunit.result.cache diff --git a/samples/server/petstore/php-lumen/lib/.styleci.yml b/samples/server/petstore/php-lumen/lib/.styleci.yml new file mode 100644 index 000000000000..89801211440a --- /dev/null +++ b/samples/server/petstore/php-lumen/lib/.styleci.yml @@ -0,0 +1,6 @@ +php: + preset: laravel + disabled: + - unused_use +js: true +css: true diff --git a/samples/server/petstore/php-lumen/lib/app/Console/Kernel.php b/samples/server/petstore/php-lumen/lib/app/Console/Kernel.php index ed6d21b681ed..d2a3066a62d4 100644 --- a/samples/server/petstore/php-lumen/lib/app/Console/Kernel.php +++ b/samples/server/petstore/php-lumen/lib/app/Console/Kernel.php @@ -1,9 +1,7 @@ [ - 'App\Listeners\ExampleListener', + \App\Events\ExampleEvent::class => [ + \App\Listeners\ExampleListener::class, ], ]; } diff --git a/samples/server/petstore/php-lumen/lib/app/User.php b/samples/server/petstore/php-lumen/lib/app/User.php index 94adde8542ee..8e330635019a 100644 --- a/samples/server/petstore/php-lumen/lib/app/User.php +++ b/samples/server/petstore/php-lumen/lib/app/User.php @@ -1,22 +1,18 @@ load(); -} catch (Dotenv\Exception\InvalidPathException $e) { - // -} +(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables( + dirname(__DIR__) +))->bootstrap(); + +date_default_timezone_set(env('APP_TIMEZONE', 'UTC')); /* |-------------------------------------------------------------------------- @@ -26,7 +24,7 @@ */ $app = new Laravel\Lumen\Application( - realpath(__DIR__.'/../') + dirname(__DIR__) ); // $app->withFacades(); @@ -54,6 +52,19 @@ 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 +77,7 @@ */ // $app->middleware([ -// App\Http\Middleware\ExampleMiddleware::class +// App\Http\Middleware\ExampleMiddleware::class // ]); // $app->routeMiddleware([ @@ -105,6 +116,4 @@ require __DIR__.'/../routes/web.php'; }); -$app->withFacades(); - return $app; diff --git a/samples/server/petstore/php-lumen/lib/composer.json b/samples/server/petstore/php-lumen/lib/composer.json index eab5c45a49c8..1d25281636a0 100644 --- a/samples/server/petstore/php-lumen/lib/composer.json +++ b/samples/server/petstore/php-lumen/lib/composer.json @@ -21,29 +21,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": { @@ -52,5 +49,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/samples/server/petstore/php-lumen/lib/database/factories/ModelFactory.php b/samples/server/petstore/php-lumen/lib/database/factories/ModelFactory.php index bf9496b0eef4..a729f9707575 100644 --- a/samples/server/petstore/php-lumen/lib/database/factories/ModelFactory.php +++ b/samples/server/petstore/php-lumen/lib/database/factories/ModelFactory.php @@ -1,17 +1,26 @@ 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/samples/server/petstore/php-lumen/lib/database/seeds/DatabaseSeeder.php b/samples/server/petstore/php-lumen/lib/database/seeds/DatabaseSeeder.php index 23526c9d99ce..427685e569e7 100644 --- a/samples/server/petstore/php-lumen/lib/database/seeds/DatabaseSeeder.php +++ b/samples/server/petstore/php-lumen/lib/database/seeds/DatabaseSeeder.php @@ -1,5 +1,9 @@ + + + + ./tests + + + + + ./app + + + + + + + + diff --git a/samples/server/petstore/php-lumen/lib/public/index.php b/samples/server/petstore/php-lumen/lib/public/index.php index 7f44de3e275d..ce8674420a52 100644 --- a/samples/server/petstore/php-lumen/lib/public/index.php +++ b/samples/server/petstore/php-lumen/lib/public/index.php @@ -1,9 +1,7 @@ get('/', function () use ($router) { return $router->app->version(); }); @@ -28,216 +43,266 @@ * Notes: To test special tags and operation ID starting with number */ $router->patch('/v2/another-fake/dummy', 'AnotherFakeApi@call123TestSpecialTags'); + +/** + * get fooGet + * Summary: + * Notes: + */ +$router->get('/v2/foo', 'DefaultApi@fooGet'); + /** * patch testClientModel * Summary: To test \"client\" model * Notes: To test \"client\" model */ $router->patch('/v2/fake', 'FakeApi@testClientModel'); + /** * post testEndpointParameters - * Summary: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * Notes: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Summary: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Notes: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 */ $router->post('/v2/fake', 'FakeApi@testEndpointParameters'); + /** * get testEnumParameters * Summary: To test enum parameters * Notes: To test enum parameters */ $router->get('/v2/fake', 'FakeApi@testEnumParameters'); + /** * delete testGroupParameters * Summary: Fake endpoint to test group parameters (optional) * Notes: Fake endpoint to test group parameters (optional) */ $router->delete('/v2/fake', 'FakeApi@testGroupParameters'); + /** * put testBodyWithFileSchema * Summary: * Notes: For this test, the body for this request much reference a schema named `File`. */ $router->put('/v2/fake/body-with-file-schema', 'FakeApi@testBodyWithFileSchema'); + /** * put testBodyWithQueryParams * Summary: * Notes: */ $router->put('/v2/fake/body-with-query-params', 'FakeApi@testBodyWithQueryParams'); + +/** + * get fakeHealthGet + * Summary: Health check endpoint + * Notes: + */ +$router->get('/v2/fake/health', 'FakeApi@fakeHealthGet'); + /** - * post createXmlItem - * Summary: creates an XmlItem - * Notes: this route creates an XmlItem + * get fakeHttpSignatureTest + * Summary: test http signature authentication + * Notes: */ -$router->post('/v2/fake/create_xml_item', 'FakeApi@createXmlItem'); +$router->get('/v2/fake/http-signature-test', 'FakeApi@fakeHttpSignatureTest'); + /** * post testInlineAdditionalProperties * Summary: test inline additionalProperties * Notes: */ $router->post('/v2/fake/inline-additionalProperties', 'FakeApi@testInlineAdditionalProperties'); + /** * get testJsonFormData * Summary: test json serialization of form data * Notes: */ $router->get('/v2/fake/jsonFormData', 'FakeApi@testJsonFormData'); + /** * post fakeOuterBooleanSerialize * Summary: * Notes: Test serialization of outer boolean types */ $router->post('/v2/fake/outer/boolean', 'FakeApi@fakeOuterBooleanSerialize'); + /** * post fakeOuterCompositeSerialize * Summary: * Notes: Test serialization of object with outer number type */ $router->post('/v2/fake/outer/composite', 'FakeApi@fakeOuterCompositeSerialize'); + /** * post fakeOuterNumberSerialize * Summary: * Notes: Test serialization of outer number types */ $router->post('/v2/fake/outer/number', 'FakeApi@fakeOuterNumberSerialize'); + /** * post fakeOuterStringSerialize * Summary: * Notes: Test serialization of outer string types */ $router->post('/v2/fake/outer/string', 'FakeApi@fakeOuterStringSerialize'); + /** * put testQueryParameterCollectionFormat * Summary: * Notes: To test the collection format in query parameters */ $router->put('/v2/fake/test-query-paramters', 'FakeApi@testQueryParameterCollectionFormat'); + /** * patch testClassname * Summary: To test class name in snake case * Notes: To test class name in snake case */ $router->patch('/v2/fake_classname_test', 'FakeClassnameTags123Api@testClassname'); + /** * post uploadFileWithRequiredFile * Summary: uploads an image (required) * Notes: */ $router->post('/v2/fake/{petId}/uploadImageWithRequiredFile', 'PetApi@uploadFileWithRequiredFile'); + /** * post addPet * Summary: Add a new pet to the store * Notes: */ $router->post('/v2/pet', 'PetApi@addPet'); + /** * put updatePet * Summary: Update an existing pet * Notes: */ $router->put('/v2/pet', 'PetApi@updatePet'); + /** * get findPetsByStatus * Summary: Finds Pets by status * Notes: Multiple status values can be provided with comma separated strings */ $router->get('/v2/pet/findByStatus', 'PetApi@findPetsByStatus'); + /** * get findPetsByTags * Summary: Finds Pets by tags * Notes: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. */ $router->get('/v2/pet/findByTags', 'PetApi@findPetsByTags'); + /** * delete deletePet * Summary: Deletes a pet * Notes: */ $router->delete('/v2/pet/{petId}', 'PetApi@deletePet'); + /** * get getPetById * Summary: Find pet by ID * Notes: Returns a single pet */ $router->get('/v2/pet/{petId}', 'PetApi@getPetById'); + /** * post updatePetWithForm * Summary: Updates a pet in the store with form data * Notes: */ $router->post('/v2/pet/{petId}', 'PetApi@updatePetWithForm'); + /** * post uploadFile * Summary: uploads an image * Notes: */ $router->post('/v2/pet/{petId}/uploadImage', 'PetApi@uploadFile'); + /** * get getInventory * Summary: Returns pet inventories by status * Notes: Returns a map of status codes to quantities */ $router->get('/v2/store/inventory', 'StoreApi@getInventory'); + /** * post placeOrder * Summary: Place an order for a pet * Notes: */ $router->post('/v2/store/order', 'StoreApi@placeOrder'); + /** * delete deleteOrder * Summary: Delete purchase order by ID * Notes: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors */ $router->delete('/v2/store/order/{order_id}', 'StoreApi@deleteOrder'); + /** * get getOrderById * Summary: Find purchase order by ID * Notes: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions */ $router->get('/v2/store/order/{order_id}', 'StoreApi@getOrderById'); + /** * post createUser * Summary: Create user * Notes: This can only be done by the logged in user. */ $router->post('/v2/user', 'UserApi@createUser'); + /** * post createUsersWithArrayInput * Summary: Creates list of users with given input array * Notes: */ $router->post('/v2/user/createWithArray', 'UserApi@createUsersWithArrayInput'); + /** * post createUsersWithListInput * Summary: Creates list of users with given input array * Notes: */ $router->post('/v2/user/createWithList', 'UserApi@createUsersWithListInput'); + /** * get loginUser * Summary: Logs user into the system * Notes: */ $router->get('/v2/user/login', 'UserApi@loginUser'); + /** * get logoutUser * Summary: Logs out current logged in user session * Notes: */ $router->get('/v2/user/logout', 'UserApi@logoutUser'); + /** * delete deleteUser * Summary: Delete user * Notes: This can only be done by the logged in user. */ $router->delete('/v2/user/{username}', 'UserApi@deleteUser'); + /** * get getUserByName * Summary: Get user by user name * Notes: */ $router->get('/v2/user/{username}', 'UserApi@getUserByName'); + /** * put updateUser * Summary: Updated user diff --git a/samples/server/petstore/php-lumen/lib/storage/app/.gitignore b/samples/server/petstore/php-lumen/lib/storage/app/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/samples/server/petstore/php-lumen/lib/storage/app/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/samples/server/petstore/php-lumen/lib/storage/framework/cache/.gitignore b/samples/server/petstore/php-lumen/lib/storage/framework/cache/.gitignore new file mode 100644 index 000000000000..01e4a6cda9eb --- /dev/null +++ b/samples/server/petstore/php-lumen/lib/storage/framework/cache/.gitignore @@ -0,0 +1,3 @@ +* +!data/ +!.gitignore diff --git a/samples/server/petstore/php-lumen/lib/storage/framework/cache/data/.gitignore b/samples/server/petstore/php-lumen/lib/storage/framework/cache/data/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/samples/server/petstore/php-lumen/lib/storage/framework/cache/data/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/samples/server/petstore/php-lumen/lib/storage/framework/views/.gitignore b/samples/server/petstore/php-lumen/lib/storage/framework/views/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/samples/server/petstore/php-lumen/lib/storage/framework/views/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/samples/server/petstore/php-lumen/lib/storage/logs/.gitignore b/samples/server/petstore/php-lumen/lib/storage/logs/.gitignore index c96a04f008ee..d6b7ef32c847 100644 --- a/samples/server/petstore/php-lumen/lib/storage/logs/.gitignore +++ b/samples/server/petstore/php-lumen/lib/storage/logs/.gitignore @@ -1,2 +1,2 @@ * -!.gitignore \ No newline at end of file +!.gitignore diff --git a/samples/server/petstore/php-lumen/lib/tests/ExampleTest.php b/samples/server/petstore/php-lumen/lib/tests/ExampleTest.php index 1bad6ef7ed7d..25a302bec884 100644 --- a/samples/server/petstore/php-lumen/lib/tests/ExampleTest.php +++ b/samples/server/petstore/php-lumen/lib/tests/ExampleTest.php @@ -1,5 +1,9 @@