-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.php
More file actions
59 lines (46 loc) · 1.65 KB
/
app.php
File metadata and controls
59 lines (46 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
//error_reporting(E_ALL);
/* LOAD COMPOSER */
require_once __DIR__ . '/../vendor/autoload.php';
/* LOAD .env */
(new Dotenv\Dotenv(__DIR__ . '/../'))->load();
/* START LUMEN */
$app = new Laravel\Lumen\Application(
realpath(__DIR__ . '/../')
);
/* ADD ELOQUENT */
$app->withFacades(true, [
Tymon\JWTAuth\Facades\JWTAuth::class => 'JWTAuth',
Tymon\JWTAuth\Facades\JWTFactory::class => 'JWTFactory'
]);
$app->withEloquent();
$app->configure('broadcasting');
/* JWT AUTHENTIFICATION */
//https://github.com/tymondesigns/jwt-auth/issues/1102#issuecomment-296712123
$app->register(Tymon\JWTAuth\Providers\LumenServiceProvider::class);
/* WEBSOCKET */
$app->register(\Illuminate\Redis\RedisServiceProvider::class);
$app->register(App\Providers\BroadcastServiceProvider::class); //(Broadcast routes)
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class, Laravel\Lumen\Exceptions\Handler::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class, Laravel\Lumen\Console\Kernel::class
);
/* MIDDLEWARES */
$app->routeMiddleware([
'jwt-auth' => App\Http\Middleware\Authenticate::class,
]);
//use Auth;
$app->router->group(['middleware' => 'jwt-auth'], function($router) {
$router->post('/broadcasting/auth', function(Illuminate\Http\Request $request) {
Illuminate\Support\Facades\Broadcast::auth($request);
});
});
$app->router->group(['namespace' => 'App\Http\Controllers'], function ($router) {
require __DIR__ . '/../routes/api.php';
});
/* RUN */
return $app;