Skip to content

Commit 05f177b

Browse files
authored
[PHP-Lumen] Lumen 5.6 support (#212)
* Lumen 5.6 support * recall headlines * Update composer.mustache * regenerate lumne php petstore samples * remove output format from lumen routes * Fix: "A facade root has not been set" * Ignore log folder
1 parent b1921ce commit 05f177b

Some content is hidden

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

51 files changed

+875
-91
lines changed

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,37 @@ public PhpLumenServerCodegen() {
9999
* entire object tree available. If the input file has a suffix of `.mustache
100100
* it will be processed by the template engine. Otherwise, it will be copied
101101
*/
102+
supportingFiles.add(new SupportingFile(".env.example", packagePath + File.separator + srcBasePath, ".env.example"));
103+
supportingFiles.add(new SupportingFile("storage_logs_.gitignore", packagePath + File.separator + srcBasePath + File.separator + "storage" + File.separator + "logs", ".gitignore"));
104+
supportingFiles.add(new SupportingFile("artisan", packagePath + File.separator + srcBasePath, "artisan"));
102105
supportingFiles.add(new SupportingFile("composer.mustache", packagePath + File.separator + srcBasePath, "composer.json"));
103106
supportingFiles.add(new SupportingFile("readme.md", packagePath + File.separator + srcBasePath, "readme.md"));
104-
supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + srcBasePath + File.separator + "bootstrap", "app.php"));
105-
supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + srcBasePath + File.separator + "public", "index.php"));
106107
supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + srcBasePath + File.separator + "app", "User.php"));
107108
supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Console", "Kernel.php"));
109+
supportingFiles.add(new SupportingFile(".gitkeep", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Console" + File.separator + "Commands", ".gitkeep"));
110+
supportingFiles.add(new SupportingFile("Event.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Events", "Event.php"));
111+
supportingFiles.add(new SupportingFile("ExampleEvent.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Events", "ExampleEvent.php"));
108112
supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php"));
109-
supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http", "routes.php"));
110-
111113
supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php"));
114+
supportingFiles.add(new SupportingFile("ExampleController.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "ExampleController.php"));
112115
supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php"));
113-
116+
supportingFiles.add(new SupportingFile("ExampleMiddleware.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "ExampleMiddleware.php"));
117+
supportingFiles.add(new SupportingFile("ExampleJob.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Jobs", "ExampleJob.php"));
118+
supportingFiles.add(new SupportingFile("Job.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Jobs", "Job.php"));
119+
supportingFiles.add(new SupportingFile("ExampleListener.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Listeners", "ExampleListener.php"));
120+
supportingFiles.add(new SupportingFile("AppServiceProvider.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Providers", "AppServiceProvider.php"));
121+
supportingFiles.add(new SupportingFile("AuthServiceProvider.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Providers", "AuthServiceProvider.php"));
122+
supportingFiles.add(new SupportingFile("EventServiceProvider.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Providers", "EventServiceProvider.php"));
123+
supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + srcBasePath + File.separator + "bootstrap", "app.php"));
124+
supportingFiles.add(new SupportingFile("ModelFactory.php", packagePath + File.separator + srcBasePath + File.separator + "database" + File.separator + "factories", "ModelFactory.php"));
125+
supportingFiles.add(new SupportingFile(".gitkeep", packagePath + File.separator + srcBasePath + File.separator + "database" + File.separator + "migrations", ".gitkeep"));
126+
supportingFiles.add(new SupportingFile("DatabaseSeeder.php", packagePath + File.separator + srcBasePath + File.separator + "database" + File.separator + "seeds", "DatabaseSeeder.php"));
127+
supportingFiles.add(new SupportingFile(".htaccess", packagePath + File.separator + srcBasePath + File.separator + "public", ".htaccess"));
128+
supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + srcBasePath + File.separator + "public", "index.php"));
129+
supportingFiles.add(new SupportingFile(".gitkeep", packagePath + File.separator + srcBasePath + File.separator + "resources" + File.separator + "views", ".gitkeep"));
130+
supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + srcBasePath + File.separator + "routes", "web.php"));
131+
supportingFiles.add(new SupportingFile("ExampleTest.php", packagePath + File.separator + srcBasePath + File.separator + "tests", "ExampleTest.php"));
132+
supportingFiles.add(new SupportingFile("TestCase.php", packagePath + File.separator + srcBasePath + File.separator + "tests", "TestCase.php"));
114133
}
115134

116135
// override with any special post-processing
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
APP_ENV=local
2+
APP_DEBUG=true
3+
APP_KEY=
4+
APP_TIMEZONE=UTC
5+
6+
LOG_CHANNEL=stack
7+
LOG_SLACK_WEBHOOK_URL=
8+
9+
DB_CONNECTION=mysql
10+
DB_HOST=127.0.0.1
11+
DB_PORT=3306
12+
DB_DATABASE=homestead
13+
DB_USERNAME=homestead
14+
DB_PASSWORD=secret
15+
16+
CACHE_DRIVER=file
17+
QUEUE_DRIVER=sync

modules/openapi-generator/src/main/resources/lumen/.gitkeep

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<IfModule mod_rewrite.c>
2+
<IfModule mod_negotiation.c>
3+
Options -MultiViews -Indexes
4+
</IfModule>
5+
6+
RewriteEngine On
7+
8+
# Handle Authorization Header
9+
RewriteCond %{HTTP:Authorization} .
10+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
11+
12+
# Redirect Trailing Slashes If Not A Folder...
13+
RewriteCond %{REQUEST_FILENAME} !-d
14+
RewriteCond %{REQUEST_URI} (.+)/$
15+
RewriteRule ^ %1 [L,R=301]
16+
17+
# Handle Front Controller...
18+
RewriteCond %{REQUEST_FILENAME} !-d
19+
RewriteCond %{REQUEST_FILENAME} !-f
20+
RewriteRule ^ index.php [L]
21+
</IfModule>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class AppServiceProvider extends ServiceProvider
8+
{
9+
/**
10+
* Register any application services.
11+
*
12+
* @return void
13+
*/
14+
public function register()
15+
{
16+
//
17+
}
18+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use App\User;
6+
use Illuminate\Support\Facades\Gate;
7+
use Illuminate\Support\ServiceProvider;
8+
9+
class AuthServiceProvider extends ServiceProvider
10+
{
11+
/**
12+
* Register any application services.
13+
*
14+
* @return void
15+
*/
16+
public function register()
17+
{
18+
//
19+
}
20+
21+
/**
22+
* Boot the authentication services for the application.
23+
*
24+
* @return void
25+
*/
26+
public function boot()
27+
{
28+
// Here you may define how you wish users to be authenticated for your Lumen
29+
// application. The callback which receives the incoming request instance
30+
// should return either a User instance or null. You're free to obtain
31+
// the User instance via an API token or any other method necessary.
32+
33+
$this->app['auth']->viaRequest('api', function ($request) {
34+
if ($request->input('api_token')) {
35+
return User::where('api_token', $request->input('api_token'))->first();
36+
}
37+
});
38+
}
39+
}

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

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

3-
/**
3+
/*
44
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
55
* https://openapi-generator.tech
66
* Do not edit the class manually.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
use Illuminate\Database\Seeder;
4+
5+
class DatabaseSeeder extends Seeder
6+
{
7+
/**
8+
* Run the database seeds.
9+
*
10+
* @return void
11+
*/
12+
public function run()
13+
{
14+
// $this->call('UsersTableSeeder');
15+
}
16+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace App\Events;
4+
5+
use Illuminate\Queue\SerializesModels;
6+
7+
abstract class Event
8+
{
9+
use SerializesModels;
10+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
6+
7+
class EventServiceProvider extends ServiceProvider
8+
{
9+
/**
10+
* The event listener mappings for the application.
11+
*
12+
* @var array
13+
*/
14+
protected $listen = [
15+
'App\Events\ExampleEvent' => [
16+
'App\Listeners\ExampleListener',
17+
],
18+
];
19+
}

0 commit comments

Comments
 (0)