Skip to content

Commit 7622b37

Browse files
committed
feat (PHP LARAVEL) 8417: add sample petstore server
1 parent ad9d79f commit 7622b37

Some content is hidden

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

68 files changed

+2607
-28
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=base64:Rftzh5fw/3aLT8zlkCMr2cT7WoRh9taPgDtkEfk+wFo=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
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+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
SESSION_DRIVER=file
19+
SESSION_LIFETIME=120
20+
QUEUE_DRIVER=sync
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
33+
PUSHER_APP_ID=
34+
PUSHER_APP_KEY=
35+
PUSHER_APP_SECRET=
36+
PUSHER_APP_CLUSTER=mt1
37+
38+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
39+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
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+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
SESSION_DRIVER=file
19+
SESSION_LIFETIME=120
20+
QUEUE_DRIVER=sync
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
33+
PUSHER_APP_ID=
34+
PUSHER_APP_KEY=
35+
PUSHER_APP_SECRET=
36+
PUSHER_APP_CLUSTER=mt1
37+
38+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
39+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

samples/server/petstore/php-laravel/lib/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,12 @@ This example uses the [laravel Framework](http://laravel.com/). To see how to m
1212

1313
Using `composer install` to install the framework and dependencies via [Composer](http://getcomposer.org/).
1414

15+
### post installation steps
16+
17+
Change into application folder and execute following commands to get started:
18+
19+
```sh
20+
cp .env.example .env
21+
php artisan key:generate
22+
php artisan serve
23+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* The Artisan commands provided by your application.
12+
*
13+
* @var array
14+
*/
15+
protected $commands = [
16+
//
17+
];
18+
19+
/**
20+
* Define the application's command schedule.
21+
*
22+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
23+
* @return void
24+
*/
25+
protected function schedule(Schedule $schedule)
26+
{
27+
// $schedule->command('inspire')
28+
// ->hourly();
29+
}
30+
31+
/**
32+
* Register the commands for the application.
33+
*
34+
* @return void
35+
*/
36+
protected function commands()
37+
{
38+
$this->load(__DIR__.'/Commands');
39+
40+
require base_path('routes/console.php');
41+
}
42+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Exception;
6+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* A list of the exception types that are not reported.
12+
*
13+
* @var array
14+
*/
15+
protected $dontReport = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the inputs that are never flashed for validation exceptions.
21+
*
22+
* @var array
23+
*/
24+
protected $dontFlash = [
25+
'password',
26+
'password_confirmation',
27+
];
28+
29+
/**
30+
* Report or log an exception.
31+
*
32+
* @param \Exception $exception
33+
* @return void
34+
*/
35+
public function report(Exception $exception)
36+
{
37+
parent::report($exception);
38+
}
39+
40+
/**
41+
* Render an exception into an HTTP response.
42+
*
43+
* @param \Illuminate\Http\Request $request
44+
* @param \Exception $exception
45+
* @return \Illuminate\Http\Response
46+
*/
47+
public function render($request, Exception $exception)
48+
{
49+
return parent::render($request, $exception);
50+
}
51+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace App\Http;
4+
5+
use Illuminate\Foundation\Http\Kernel as HttpKernel;
6+
7+
class Kernel extends HttpKernel
8+
{
9+
/**
10+
* The application's global HTTP middleware stack.
11+
*
12+
* These middleware are run during every request to your application.
13+
*
14+
* @var array
15+
*/
16+
protected $middleware = [
17+
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
18+
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
19+
\App\Http\Middleware\TrimStrings::class,
20+
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
21+
\App\Http\Middleware\TrustProxies::class,
22+
];
23+
24+
/**
25+
* The application's route middleware groups.
26+
*
27+
* @var array
28+
*/
29+
protected $middlewareGroups = [
30+
'web' => [
31+
\App\Http\Middleware\EncryptCookies::class,
32+
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
33+
\Illuminate\Session\Middleware\StartSession::class,
34+
// \Illuminate\Session\Middleware\AuthenticateSession::class,
35+
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
36+
\App\Http\Middleware\VerifyCsrfToken::class,
37+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
38+
],
39+
40+
'api' => [
41+
'throttle:60,1',
42+
'bindings',
43+
],
44+
];
45+
46+
/**
47+
* The application's route middleware.
48+
*
49+
* These middleware may be assigned to groups or used individually.
50+
*
51+
* @var array
52+
*/
53+
protected $routeMiddleware = [
54+
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
55+
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
56+
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
57+
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
58+
'can' => \Illuminate\Auth\Middleware\Authorize::class,
59+
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
60+
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
61+
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
62+
];
63+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
6+
7+
class EncryptCookies extends Middleware
8+
{
9+
/**
10+
* The names of the cookies that should not be encrypted.
11+
*
12+
* @var array
13+
*/
14+
protected $except = [
15+
//
16+
];
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Closure;
6+
use Illuminate\Support\Facades\Auth;
7+
8+
class RedirectIfAuthenticated
9+
{
10+
/**
11+
* Handle an incoming request.
12+
*
13+
* @param \Illuminate\Http\Request $request
14+
* @param \Closure $next
15+
* @param string|null $guard
16+
* @return mixed
17+
*/
18+
public function handle($request, Closure $next, $guard = null)
19+
{
20+
if (Auth::guard($guard)->check()) {
21+
return redirect('/home');
22+
}
23+
24+
return $next($request);
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
6+
7+
class TrimStrings extends Middleware
8+
{
9+
/**
10+
* The names of the attributes that should not be trimmed.
11+
*
12+
* @var array
13+
*/
14+
protected $except = [
15+
'password',
16+
'password_confirmation',
17+
];
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Illuminate\Http\Request;
6+
use Fideloper\Proxy\TrustProxies as Middleware;
7+
8+
class TrustProxies extends Middleware
9+
{
10+
/**
11+
* The trusted proxies for this application.
12+
*
13+
* @var array
14+
*/
15+
protected $proxies;
16+
17+
/**
18+
* The headers that should be used to detect proxies.
19+
*
20+
* @var int
21+
*/
22+
protected $headers = Request::HEADER_X_FORWARDED_ALL;
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
6+
7+
class VerifyCsrfToken extends Middleware
8+
{
9+
/**
10+
* The URIs that should be excluded from CSRF verification.
11+
*
12+
* @var array
13+
*/
14+
protected $except = [
15+
//
16+
];
17+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class AppServiceProvider extends ServiceProvider
8+
{
9+
/**
10+
* Bootstrap any application services.
11+
*
12+
* @return void
13+
*/
14+
public function boot()
15+
{
16+
//
17+
}
18+
19+
/**
20+
* Register any application services.
21+
*
22+
* @return void
23+
*/
24+
public function register()
25+
{
26+
//
27+
}
28+
}

0 commit comments

Comments
 (0)