Skip to content

Commit ba8a501

Browse files
authored
[php-lumen] Set required PHP version to ^7.2.5 (#6949)
* Set required PHP version to ^7.2.5 * Write .gitignore into srcBasePath * Update dependencies * Copy latest Lumen sources to templates * Add Lumen license template * Use Lumen license in templates * Fix typo in readme * Add Init App Config readme section * Add composer.lock to root gitignore * Add Travis-CI task * Set OAS 3.0 input spec file for samples * Refresh samples
1 parent ca3fa4b commit ba8a501

File tree

84 files changed

+626
-267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+626
-267
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ samples/client/petstore/python-asyncio/.venv/
173173
samples/client/petstore/python-asyncio/.pytest_cache/
174174
samples/client/petstore/python-tornado/.venv/
175175

176+
# PHP
177+
samples/server/petstore/php-lumen/lib/composer.lock
178+
176179
# ts
177180
samples/client/petstore/typescript-angular2/npm/npm-debug.log
178181
samples/client/petstore/typescript-node/npm/npm-debug.log

bin/configs/php-lumen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
generatorName: php-lumen
22
outputDir: samples/server/petstore/php-lumen
3-
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
44
templateDir: modules/openapi-generator/src/main/resources/php-lumen

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLumenServerCodegen.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,30 @@ public PhpLumenServerCodegen() {
105105
* are available in models, apis, and supporting files
106106
*/
107107
additionalProperties.put("apiVersion", apiVersion);
108+
}
109+
110+
@Override
111+
public void processOpts() {
112+
super.processOpts();
113+
114+
// reset supporting files defined in AbstractPhpCodegen
115+
supportingFiles.clear();
116+
117+
// AbstractPhpCodegen generates .gitignore in output folder
118+
// current build needs .gitignore in a "lib" folder which is srcBasePath
119+
supportingFiles.add(new SupportingFile("gitignore", srcBasePath, ".gitignore"));
108120

109121
/*
110122
* Supporting Files. You can write single files for the generator with the
111123
* entire object tree available. If the input file has a suffix of `.mustache
112124
* it will be processed by the template engine. Otherwise, it will be copied
113125
*/
114126
supportingFiles.add(new SupportingFile(".env.example", srcBasePath, ".env.example"));
115-
supportingFiles.add(new SupportingFile("storage_logs_.gitignore", srcBasePath + File.separator + "storage" + File.separator + "logs", ".gitignore"));
127+
supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "logs", ".gitignore"));
128+
supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "app", ".gitignore"));
129+
supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "framework" + File.separator + "views", ".gitignore"));
130+
supportingFiles.add(new SupportingFile("storage_framework_cache_gitignore", srcBasePath + File.separator + "storage" + File.separator + "framework" + File.separator + "cache", ".gitignore"));
131+
supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "framework" + File.separator + "cache" + File.separator + "data", ".gitignore"));
116132
supportingFiles.add(new SupportingFile("artisan", srcBasePath, "artisan"));
117133
supportingFiles.add(new SupportingFile("composer.mustache", srcBasePath, "composer.json"));
118134
supportingFiles.add(new SupportingFile("readme.md", srcBasePath, "readme.md"));
@@ -142,6 +158,9 @@ public PhpLumenServerCodegen() {
142158
supportingFiles.add(new SupportingFile("routes.mustache", srcBasePath + File.separator + "routes", "web.php"));
143159
supportingFiles.add(new SupportingFile("ExampleTest.php", srcBasePath + File.separator + "tests", "ExampleTest.php"));
144160
supportingFiles.add(new SupportingFile("TestCase.php", srcBasePath + File.separator + "tests", "TestCase.php"));
161+
supportingFiles.add(new SupportingFile("editorconfig", srcBasePath, ".editorconfig"));
162+
supportingFiles.add(new SupportingFile("styleci", srcBasePath, ".styleci.yml"));
163+
supportingFiles.add(new SupportingFile("phpunit.xml", srcBasePath, "phpunit.xml"));
145164
}
146165

147166
// override with any special post-processing

modules/openapi-generator/src/main/resources/php-lumen/.env.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
APP_NAME=Lumen
12
APP_ENV=local
2-
APP_DEBUG=true
33
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
46
APP_TIMEZONE=UTC
57

68
LOG_CHANNEL=stack
@@ -14,4 +16,4 @@ DB_USERNAME=homestead
1416
DB_PASSWORD=secret
1517

1618
CACHE_DRIVER=file
17-
QUEUE_DRIVER=sync
19+
QUEUE_CONNECTION=sync

modules/openapi-generator/src/main/resources/php-lumen/AppServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
namespace App\Providers;
45

56
use Illuminate\Support\ServiceProvider;

modules/openapi-generator/src/main/resources/php-lumen/AuthServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
namespace App\Providers;
45

56
use App\User;

modules/openapi-generator/src/main/resources/php-lumen/Authenticate.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<?php
22

3-
/*
4-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
5-
* https://openapi-generator.tech
6-
* Do not edit the class manually.
7-
*/
8-
3+
{{>licenseInfoLumen}}
94
namespace App\Http\Middleware;
105

116
use Closure;

modules/openapi-generator/src/main/resources/php-lumen/Controller.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<?php
22

3-
/**
4-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
5-
* https://openapi-generator.tech
6-
* Do not edit the class manually.
7-
*/
8-
3+
{{>licenseInfoLumen}}
94
namespace App\Http\Controllers;
105

116
use Laravel\Lumen\Routing\Controller as BaseController;

modules/openapi-generator/src/main/resources/php-lumen/DatabaseSeeder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
use Illuminate\Database\Seeder;
45

56
class DatabaseSeeder extends Seeder

modules/openapi-generator/src/main/resources/php-lumen/Event.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
namespace App\Events;
45

56
use Illuminate\Queue\SerializesModels;

modules/openapi-generator/src/main/resources/php-lumen/EventServiceProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
namespace App\Providers;
45

56
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
@@ -12,8 +13,8 @@ class EventServiceProvider extends ServiceProvider
1213
* @var array
1314
*/
1415
protected $listen = [
15-
'App\Events\ExampleEvent' => [
16-
'App\Listeners\ExampleListener',
16+
\App\Events\ExampleEvent::class => [
17+
\App\Listeners\ExampleListener::class,
1718
],
1819
];
1920
}

modules/openapi-generator/src/main/resources/php-lumen/ExampleController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
namespace App\Http\Controllers;
45

56
class ExampleController extends Controller

modules/openapi-generator/src/main/resources/php-lumen/ExampleEvent.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
namespace App\Events;
45

56
class ExampleEvent extends Event

modules/openapi-generator/src/main/resources/php-lumen/ExampleJob.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
namespace App\Jobs;
45

56
class ExampleJob extends Job

modules/openapi-generator/src/main/resources/php-lumen/ExampleListener.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
namespace App\Listeners;
45

56
use App\Events\ExampleEvent;
6-
use Illuminate\Queue\InteractsWithQueue;
77
use Illuminate\Contracts\Queue\ShouldQueue;
8+
use Illuminate\Queue\InteractsWithQueue;
89

910
class ExampleListener
1011
{
@@ -21,7 +22,7 @@ public function __construct()
2122
/**
2223
* Handle the event.
2324
*
24-
* @param ExampleEvent $event
25+
* @param \App\Events\ExampleEvent $event
2526
* @return void
2627
*/
2728
public function handle(ExampleEvent $event)

modules/openapi-generator/src/main/resources/php-lumen/ExampleMiddleware.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
namespace App\Http\Middleware;
45

56
use Closure;

modules/openapi-generator/src/main/resources/php-lumen/ExampleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
use Laravel\Lumen\Testing\DatabaseMigrations;
45
use Laravel\Lumen\Testing\DatabaseTransactions;
56

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
<?php
22

3-
/**
4-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
5-
* https://openapi-generator.tech
6-
* Do not edit the class manually.
7-
*/
8-
3+
{{>licenseInfoLumen}}
94
namespace App\Exceptions;
105

11-
use Exception;
12-
use Illuminate\Validation\ValidationException;
136
use Illuminate\Auth\Access\AuthorizationException;
147
use Illuminate\Database\Eloquent\ModelNotFoundException;
15-
use Symfony\Component\HttpKernel\Exception\HttpException;
8+
use Illuminate\Validation\ValidationException;
169
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
10+
use Symfony\Component\HttpKernel\Exception\HttpException;
11+
use Throwable;
1712

1813
class Handler extends ExceptionHandler
1914
{
@@ -34,23 +29,27 @@ class Handler extends ExceptionHandler
3429
*
3530
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
3631
*
37-
* @param \Exception $e
32+
* @param \Throwable $exception
3833
* @return void
34+
*
35+
* @throws \Exception
3936
*/
40-
public function report(Exception $e)
37+
public function report(Throwable $exception)
4138
{
42-
parent::report($e);
39+
parent::report($exception);
4340
}
4441

4542
/**
4643
* Render an exception into an HTTP response.
4744
*
4845
* @param \Illuminate\Http\Request $request
49-
* @param \Exception $e
50-
* @return \Illuminate\Http\Response
46+
* @param \Throwable $exception
47+
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
48+
*
49+
* @throws \Throwable
5150
*/
52-
public function render($request, Exception $e)
51+
public function render($request, Throwable $exception)
5352
{
54-
return parent::render($request, $e);
53+
return parent::render($request, $exception);
5554
}
5655
}

modules/openapi-generator/src/main/resources/php-lumen/Job.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
34
namespace App\Jobs;
45

56
use Illuminate\Bus\Queueable;
6-
use Illuminate\Queue\SerializesModels;
7-
use Illuminate\Queue\InteractsWithQueue;
87
use Illuminate\Contracts\Queue\ShouldQueue;
8+
use Illuminate\Queue\InteractsWithQueue;
9+
use Illuminate\Queue\SerializesModels;
910

1011
abstract class Job implements ShouldQueue
1112
{

modules/openapi-generator/src/main/resources/php-lumen/Kernel.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<?php
22

3-
/**
4-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
5-
* https://openapi-generator.tech
6-
* Do not edit the class manually.
7-
*/
8-
3+
{{>licenseInfoLumen}}
94
namespace App\Console;
105

116
use Illuminate\Console\Scheduling\Schedule;

modules/openapi-generator/src/main/resources/php-lumen/ModelFactory.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
<?php
22

3+
{{>licenseInfoLumen}}
4+
/** @var \Illuminate\Database\Eloquent\Factory $factory */
5+
6+
use App\User;
7+
use Faker\Generator as Faker;
8+
39
/*
410
|--------------------------------------------------------------------------
511
| Model Factories
612
|--------------------------------------------------------------------------
713
|
8-
| Here you may define all of your model factories. Model factories give
9-
| you a convenient way to create models for testing and seeding your
10-
| database. Just tell the factory how a default model should look.
14+
| This directory should contain each of the model factory definitions for
15+
| your application. Factories provide a convenient way to generate new
16+
| model instances for testing / seeding your application's database.
1117
|
1218
*/
1319

14-
$factory->define(App\User::class, function (Faker\Generator $faker) {
20+
$factory->define(User::class, function (Faker $faker) {
1521
return [
1622
'name' => $faker->name,
1723
'email' => $faker->email,

modules/openapi-generator/src/main/resources/php-lumen/TestCase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

3-
abstract class TestCase extends Laravel\Lumen\Testing\TestCase
3+
{{>licenseInfoLumen}}
4+
use Laravel\Lumen\Testing\TestCase as BaseTestCase;
5+
6+
abstract class TestCase extends BaseTestCase
47
{
58
/**
69
* Creates the application.

modules/openapi-generator/src/main/resources/php-lumen/User.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
<?php
22

3-
/**
4-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
5-
* https://openapi-generator.tech
6-
* Do not edit the class manually.
7-
*/
8-
3+
{{>licenseInfoLumen}}
94
namespace App;
105

116
use Illuminate\Auth\Authenticatable;
12-
use Laravel\Lumen\Auth\Authorizable;
13-
use Illuminate\Database\Eloquent\Model;
14-
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
157
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
8+
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
9+
use Illuminate\Database\Eloquent\Model;
10+
use Laravel\Lumen\Auth\Authorizable;
1611

17-
class User extends Model implements
18-
AuthenticatableContract,
19-
AuthorizableContract
12+
class User extends Model implements AuthenticatableContract, AuthorizableContract
2013
{
2114
use Authenticatable, Authorizable;
2215

0 commit comments

Comments
 (0)