summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Console/Commands/.gitkeep0
-rw-r--r--app/Console/Kernel.php29
-rw-r--r--app/Events/Event.php10
-rw-r--r--app/Events/ExampleEvent.php16
-rw-r--r--app/Exceptions/Handler.php50
-rw-r--r--app/Http/Controllers/Controller.php10
-rw-r--r--app/Http/Controllers/ExampleController.php18
-rw-r--r--app/Http/Middleware/Authenticate.php44
-rw-r--r--app/Http/Middleware/ExampleMiddleware.php20
-rw-r--r--app/Http/routes.php16
-rw-r--r--app/Jobs/ExampleJob.php26
-rw-r--r--app/Jobs/Job.php24
-rw-r--r--app/Listeners/ExampleListener.php31
-rw-r--r--app/Providers/AppServiceProvider.php18
-rw-r--r--app/Providers/AuthServiceProvider.php40
-rw-r--r--app/Providers/EventServiceProvider.php19
-rw-r--r--app/User.php34
17 files changed, 405 insertions, 0 deletions
diff --git a/app/Console/Commands/.gitkeep b/app/Console/Commands/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/Console/Commands/.gitkeep
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
new file mode 100644
index 0000000..ad6e311
--- /dev/null
+++ b/app/Console/Kernel.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Console;
+
+use Illuminate\Console\Scheduling\Schedule;
+use Laravel\Lumen\Console\Kernel as ConsoleKernel;
+
+class Kernel extends ConsoleKernel
+{
+ /**
+ * The Artisan commands provided by your application.
+ *
+ * @var array
+ */
+ protected $commands = [
+ //
+ ];
+
+ /**
+ * Define the application's command schedule.
+ *
+ * @param \Illuminate\Console\Scheduling\Schedule $schedule
+ * @return void
+ */
+ protected function schedule(Schedule $schedule)
+ {
+ //
+ }
+}
diff --git a/app/Events/Event.php b/app/Events/Event.php
new file mode 100644
index 0000000..b8230f0
--- /dev/null
+++ b/app/Events/Event.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Events;
+
+use Illuminate\Queue\SerializesModels;
+
+abstract class Event
+{
+ use SerializesModels;
+}
diff --git a/app/Events/ExampleEvent.php b/app/Events/ExampleEvent.php
new file mode 100644
index 0000000..4bd1268
--- /dev/null
+++ b/app/Events/ExampleEvent.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Events;
+
+class ExampleEvent extends Event
+{
+ /**
+ * Create a new event instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ //
+ }
+}
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
new file mode 100644
index 0000000..abb8a44
--- /dev/null
+++ b/app/Exceptions/Handler.php
@@ -0,0 +1,50 @@
+<?php
+
+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;
+
+class Handler extends ExceptionHandler
+{
+ /**
+ * A list of the exception types that should not be reported.
+ *
+ * @var array
+ */
+ protected $dontReport = [
+ AuthorizationException::class,
+ HttpException::class,
+ ModelNotFoundException::class,
+ ValidationException::class,
+ ];
+
+ /**
+ * Report or log an exception.
+ *
+ * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
+ *
+ * @param \Exception $e
+ * @return void
+ */
+ public function report(Exception $e)
+ {
+ parent::report($e);
+ }
+
+ /**
+ * Render an exception into an HTTP response.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Exception $e
+ * @return \Illuminate\Http\Response
+ */
+ public function render($request, Exception $e)
+ {
+ return parent::render($request, $e);
+ }
+}
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
new file mode 100644
index 0000000..0ccb918
--- /dev/null
+++ b/app/Http/Controllers/Controller.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Laravel\Lumen\Routing\Controller as BaseController;
+
+class Controller extends BaseController
+{
+ //
+}
diff --git a/app/Http/Controllers/ExampleController.php b/app/Http/Controllers/ExampleController.php
new file mode 100644
index 0000000..aab066e
--- /dev/null
+++ b/app/Http/Controllers/ExampleController.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Http\Controllers;
+
+class ExampleController extends Controller
+{
+ /**
+ * Create a new controller instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ //
+ }
+
+ //
+}
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
new file mode 100644
index 0000000..361a11e
--- /dev/null
+++ b/app/Http/Middleware/Authenticate.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+use Illuminate\Contracts\Auth\Factory as Auth;
+
+class Authenticate
+{
+ /**
+ * The authentication guard factory instance.
+ *
+ * @var \Illuminate\Contracts\Auth\Factory
+ */
+ protected $auth;
+
+ /**
+ * Create a new middleware instance.
+ *
+ * @param \Illuminate\Contracts\Auth\Factory $auth
+ * @return void
+ */
+ public function __construct(Auth $auth)
+ {
+ $this->auth = $auth;
+ }
+
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @param string|null $guard
+ * @return mixed
+ */
+ public function handle($request, Closure $next, $guard = null)
+ {
+ if ($this->auth->guard($guard)->guest()) {
+ return response('Unauthorized.', 401);
+ }
+
+ return $next($request);
+ }
+}
diff --git a/app/Http/Middleware/ExampleMiddleware.php b/app/Http/Middleware/ExampleMiddleware.php
new file mode 100644
index 0000000..166581c
--- /dev/null
+++ b/app/Http/Middleware/ExampleMiddleware.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+
+class ExampleMiddleware
+{
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @return mixed
+ */
+ public function handle($request, Closure $next)
+ {
+ return $next($request);
+ }
+}
diff --git a/app/Http/routes.php b/app/Http/routes.php
new file mode 100644
index 0000000..f2c5b17
--- /dev/null
+++ b/app/Http/routes.php
@@ -0,0 +1,16 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| Application Routes
+|--------------------------------------------------------------------------
+|
+| Here is where you can register all of the routes for an application.
+| It is a breeze. Simply tell Lumen the URIs it should respond to
+| and give it the Closure to call when that URI is requested.
+|
+*/
+
+$app->get('/', function () use ($app) {
+ return $app->version();
+});
diff --git a/app/Jobs/ExampleJob.php b/app/Jobs/ExampleJob.php
new file mode 100644
index 0000000..7b65bb4
--- /dev/null
+++ b/app/Jobs/ExampleJob.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Jobs;
+
+class ExampleJob extends Job
+{
+ /**
+ * Create a new job instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ //
+ }
+
+ /**
+ * Execute the job.
+ *
+ * @return void
+ */
+ public function handle()
+ {
+ //
+ }
+}
diff --git a/app/Jobs/Job.php b/app/Jobs/Job.php
new file mode 100644
index 0000000..7c873e1
--- /dev/null
+++ b/app/Jobs/Job.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Jobs;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Contracts\Queue\ShouldQueue;
+
+abstract class Job implements ShouldQueue
+{
+ /*
+ |--------------------------------------------------------------------------
+ | Queueable Jobs
+ |--------------------------------------------------------------------------
+ |
+ | This job base class provides a central location to place any logic that
+ | is shared across all of your jobs. The trait included with the class
+ | provides access to the "queueOn" and "delay" queue helper methods.
+ |
+ */
+
+ use InteractsWithQueue, Queueable, SerializesModels;
+}
diff --git a/app/Listeners/ExampleListener.php b/app/Listeners/ExampleListener.php
new file mode 100644
index 0000000..77fc6a8
--- /dev/null
+++ b/app/Listeners/ExampleListener.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace App\Listeners;
+
+use App\Events\ExampleEvent;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Contracts\Queue\ShouldQueue;
+
+class ExampleListener
+{
+ /**
+ * Create the event listener.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ //
+ }
+
+ /**
+ * Handle the event.
+ *
+ * @param ExampleEvent $event
+ * @return void
+ */
+ public function handle(ExampleEvent $event)
+ {
+ //
+ }
+}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
new file mode 100644
index 0000000..ddec046
--- /dev/null
+++ b/app/Providers/AppServiceProvider.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Support\ServiceProvider;
+
+class AppServiceProvider extends ServiceProvider
+{
+ /**
+ * Register any application services.
+ *
+ * @return void
+ */
+ public function register()
+ {
+ //
+ }
+}
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php
new file mode 100644
index 0000000..3565688
--- /dev/null
+++ b/app/Providers/AuthServiceProvider.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace App\Providers;
+
+use App\User;
+use Illuminate\Support\Facades\Auth;
+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.
+
+ Auth::viaRequest('api', function ($request) {
+ if ($request->input('api_token')) {
+ return User::where('api_token', $request->input('api_token'))->first();
+ }
+ });
+ }
+}
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
new file mode 100644
index 0000000..0b8f393
--- /dev/null
+++ b/app/Providers/EventServiceProvider.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Providers;
+
+use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
+
+class EventServiceProvider extends ServiceProvider
+{
+ /**
+ * The event listener mappings for the application.
+ *
+ * @var array
+ */
+ protected $listen = [
+ 'App\Events\SomeEvent' => [
+ 'App\Listeners\EventListener',
+ ],
+ ];
+}
diff --git a/app/User.php b/app/User.php
new file mode 100644
index 0000000..fd4de31
--- /dev/null
+++ b/app/User.php
@@ -0,0 +1,34 @@
+<?php
+
+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;
+
+class User extends Model implements
+ AuthenticatableContract,
+ AuthorizableContract
+{
+ use Authenticatable, Authorizable;
+
+ /**
+ * The attributes that are mass assignable.
+ *
+ * @var array
+ */
+ protected $fillable = [
+ 'name', 'email',
+ ];
+
+ /**
+ * The attributes excluded from the model's JSON form.
+ *
+ * @var array
+ */
+ protected $hidden = [
+ 'password',
+ ];
+}