Skip to content

Commit

Permalink
[php-lumen] Set required PHP version to ^7.2.5 (#6949)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ybelenko authored Aug 4, 2020
1 parent ca3fa4b commit ba8a501
Show file tree
Hide file tree
Showing 84 changed files with 626 additions and 267 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bin/configs/php-lumen.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,30 @@ 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
* entire object tree available. If the input file has a suffix of `.mustache
* 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"));
Expand Down Expand Up @@ -142,6 +158,9 @@ public PhpLumenServerCodegen() {
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,4 +16,4 @@ DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
QUEUE_DRIVER=sync
QUEUE_CONNECTION=sync
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

{{>licenseInfoLumen}}
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

{{>licenseInfoLumen}}
namespace App\Providers;

use App\User;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php

/*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

{{>licenseInfoLumen}}
namespace App\Http\Middleware;

use Closure;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php

/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

{{>licenseInfoLumen}}
namespace App\Http\Controllers;

use Laravel\Lumen\Routing\Controller as BaseController;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

{{>licenseInfoLumen}}
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

{{>licenseInfoLumen}}
namespace App\Events;

use Illuminate\Queue\SerializesModels;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

{{>licenseInfoLumen}}
namespace App\Providers;

use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
Expand All @@ -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,
],
];
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

{{>licenseInfoLumen}}
namespace App\Http\Controllers;

class ExampleController extends Controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

{{>licenseInfoLumen}}
namespace App\Events;

class ExampleEvent extends Event
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

{{>licenseInfoLumen}}
namespace App\Jobs;

class ExampleJob extends Job
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

{{>licenseInfoLumen}}
namespace App\Listeners;

use App\Events\ExampleEvent;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class ExampleListener
{
Expand All @@ -21,7 +22,7 @@ public function __construct()
/**
* Handle the event.
*
* @param ExampleEvent $event
* @param \App\Events\ExampleEvent $event
* @return void
*/
public function handle(ExampleEvent $event)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

{{>licenseInfoLumen}}
namespace App\Http\Middleware;

use Closure;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

{{>licenseInfoLumen}}
use Laravel\Lumen\Testing\DatabaseMigrations;
use Laravel\Lumen\Testing\DatabaseTransactions;

Expand Down
31 changes: 15 additions & 16 deletions modules/openapi-generator/src/main/resources/php-lumen/Handler.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
<?php

/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

{{>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
{
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

{{>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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php

/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

{{>licenseInfoLumen}}
namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
<?php

{{>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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

abstract class TestCase extends Laravel\Lumen\Testing\TestCase
{{>licenseInfoLumen}}
use Laravel\Lumen\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
/**
* Creates the application.
Expand Down
17 changes: 5 additions & 12 deletions modules/openapi-generator/src/main/resources/php-lumen/User.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
<?php

/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

{{>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;

Expand Down
Loading

0 comments on commit ba8a501

Please sign in to comment.