Skip to content

Commit

Permalink
Working lumen 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
0plus1 committed May 31, 2016
1 parent eba3a50 commit 3d2409f
Show file tree
Hide file tree
Showing 6 changed files with 750 additions and 784 deletions.
15 changes: 8 additions & 7 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
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 Laravel\Lumen\Exceptions\Handler as ExceptionHandler;

Expand All @@ -14,7 +17,10 @@ class Handler extends ExceptionHandler
* @var array
*/
protected $dontReport = [
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];

/**
Expand All @@ -27,7 +33,7 @@ class Handler extends ExceptionHandler
*/
public function report(Exception $e)
{
return parent::report($e);
parent::report($e);
}

/**
Expand All @@ -39,11 +45,6 @@ public function report(Exception $e)
*/
public function render($request, Exception $e)
{
$response = parent::render($request, $e);
// if ($request->is('api/*')) { // Add this if you want to filter specific requests
// We force cors headers on exception errors as well, dingo/api uses exceptions everywhere
app('Barryvdh\Cors\Stack\CorsService')->addActualRequestHeaders($response, $request);

return $response;
return parent::render($request, $e);
}
}
39 changes: 39 additions & 0 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Providers;

use App\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}

/**
* Boot the authentication services for the application.
*
* @return void
*/
public function boot()
{
// Here you may define how you wish users to be authenticated for your Lumen
// application. The callback which receives the incoming request instance
// should return either a User instance or null. You're free to obtain
// the User instance via an API token or any other method necessary.

$this->app['auth']->viaRequest('api', function ($request) {
if ($request->input('api_token')) {
return User::where('api_token', $request->input('api_token'))->first();
}
});
}
}
8 changes: 6 additions & 2 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

require_once __DIR__.'/../vendor/autoload.php';

Dotenv::load(__DIR__.'/../');
try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -69,7 +73,7 @@
]);

// $app->routeMiddleware([

// 'auth' => App\Http\Middleware\Authenticate::class,
// ]);

/*
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/lumen-framework": "5.1.*",
"vlucas/phpdotenv": "~1.0",
"dingo/api": "dev-master#cde3390",
"tymon/jwt-auth": "0.6.*@dev",
"laravel/lumen-framework": "5.2.*",
"vlucas/phpdotenv": "~2.2",
"dingo/api": "dev-master",
"tymon/jwt-auth": "dev-master#dfd929d",
"barryvdh/laravel-cors": "^0.8.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"fzaninotto/faker": "~1.0"
"fzaninotto/faker": "~1.4",
"phpunit/phpunit": "~4.0"
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/"
]
}
},
"autoload-dev": {
"classmap": [
"tests/"
"tests/",
"database/"
]
},
"config": {
"preferred-install": "dist"
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
]
}
}
Loading

0 comments on commit 3d2409f

Please sign in to comment.