From c270906bd162c987b062c86413070c8c870e9fa4 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2019 18:30:00 +1100 Subject: [PATCH 01/12] Update composer --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 6b59ba5..4871c48 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "specialtactics/l5-api-boilerplate", - "description": "An API boilerplate for Laravel 5", + "name": "specialtactics/laravel-api-boilerplate", + "description": "An API boilerplate for Laravel", "keywords": ["laravel", "boilerplate", "api", "api boilerplate", "laravel api"], "license": "MIT", "type": "project", @@ -11,11 +11,11 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2", "fideloper/proxy": "^4.0", - "laravel/framework": "5.8.*", + "laravel/framework": "^6", "laravel/tinker": "^1.0", - "specialtactics/l5-api": "~1", + "specialtactics/l5-api": "^1", "predis/predis": "^1.1" }, "require-dev": { @@ -26,7 +26,7 @@ "laravel/telescope": "~2.0", "mockery/mockery": "^1.0", "nunomaduro/collision": "^3.0", - "phpunit/phpunit": "^7.5" + "phpunit/phpunit": "^8.3" }, "config": { "optimize-autoloader": true, From 83647b5fce84289bf82745324dbad208efc43e5f Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2019 20:08:14 +1100 Subject: [PATCH 02/12] Another composer update --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4871c48..b671c1e 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "beyondcode/laravel-dump-server": "^1.0", "filp/whoops": "^2.0", "fzaninotto/faker": "^1.4", - "laravel/telescope": "~2.0", + "laravel/telescope": "^2", "mockery/mockery": "^1.0", "nunomaduro/collision": "^3.0", "phpunit/phpunit": "^8.3" From 9b07693ba0fe45ffbf01b350aa884580c3ffb5eb Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2019 22:06:31 +1100 Subject: [PATCH 03/12] Updating base files to keep up to date with laravel 6 --- .editorconfig | 15 ++- .env.example | 9 +- .gitignore | 16 ++-- .styleci.yml | 36 +++---- app/Http/Kernel.php | 4 +- app/Http/Middleware/TrustProxies.php | 4 +- app/Models/User.php | 2 +- app/Providers/AuthServiceProvider.php | 2 +- app/Providers/BroadcastServiceProvider.php | 2 +- app/Providers/EventServiceProvider.php | 6 +- app/Providers/RouteServiceProvider.php | 8 +- composer.json | 5 +- config/auth.php | 14 +++ config/broadcasting.php | 2 +- config/cache.php | 1 + config/database.php | 13 ++- config/filesystems.php | 2 +- config/logging.php | 6 ++ config/mail.php | 4 +- config/queue.php | 1 + config/services.php | 20 +--- database/.gitignore | 1 + database/factories/UserFactory.php | 10 +- .../2018_04_30_000010_create_users_table.php | 1 + ..._08_19_000000_create_failed_jobs_table.php | 35 +++++++ database/seeds/DatabaseSeeder.php | 2 +- phpunit.xml | 14 +-- public/index.php | 2 + resources/lang/en/passwords.php | 1 - resources/lang/en/validation.php | 2 + resources/views/welcome.blade.php | 96 ------------------- routes/api.php | 4 - server.php | 2 + tests/Feature/ExampleTest.php | 2 +- tests/Unit/ExampleTest.php | 2 +- 35 files changed, 161 insertions(+), 185 deletions(-) create mode 100644 database/migrations/2019_08_19_000000_create_failed_jobs_table.php delete mode 100644 resources/views/welcome.blade.php diff --git a/.editorconfig b/.editorconfig index 1da1dca..730726c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,13 +2,20 @@ root = true [*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true indent_style = space indent_size = 4 -end_of_line = lf -charset = utf-8 trim_trailing_whitespace = true -insert_final_newline = true -[*.{json,yml}] +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] indent_style = space indent_size = 2 + +[*.{js,json}] +indent_style = space +indent_size = 2 \ No newline at end of file diff --git a/.env.example b/.env.example index 632b5f6..4b71520 100644 --- a/.env.example +++ b/.env.example @@ -27,7 +27,7 @@ DB_PASSWORD=secret BROADCAST_DRIVER=log CACHE_DRIVER=file -QUEUE_DRIVER=redis +QUEUE_CONNECTION=redis REDIS_HOST=your_project_redis REDIS_PASSWORD=null @@ -40,6 +40,11 @@ MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= + PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= @@ -69,7 +74,7 @@ DATA_PATH_HOST=./storage/laradock/ ### PHP ########################################### -# Select a PHP version of the Workspace and PHP-FPM containers (Does not apply to HHVM). Accepted values: 7.2 - 7.1 - 7.0 - 5.6 - 5.5 +# Select a PHP version of the Workspace and PHP-FPM containers (Does not apply to HHVM). Accepted values: 7.2, 7.3 PHP_VERSION=7.3 # Enable Xdebug diff --git a/.gitignore b/.gitignore index 9dff324..ddc8e99 100644 --- a/.gitignore +++ b/.gitignore @@ -3,20 +3,18 @@ /public/storage /storage/*.key /vendor -/.idea -/.vscode -/.vagrant +.env +.env.backup +.phpunit.result.cache Homestead.json Homestead.yaml npm-debug.log yarn-error.log -.env -composer.lock - +/.idea +/.vscode +/.vagrant .phpstorm* _ide_helper.php - -# mac os -.DS_Store +.DS_Store \ No newline at end of file diff --git a/.styleci.yml b/.styleci.yml index 6c77e9e..60e3989 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,16 +1,20 @@ -preset: laravel - -enabled: - -disabled: - - length_ordered_imports - - no_unused_imports - - phpdoc_summary - - phpdoc_var_without_name - - post_increment - -finder: - exclude: - - "tests" - - "storage" - - "vendor" \ No newline at end of file +php: + preset: laravel + enabled: + - alpha_ordered_imports + disabled: + - length_ordered_imports + - unused_use + finder: + not-name: + - index.php + - server.php + exclude: + - "tests" + - "storage" + - "vendor" +js: + finder: + not-name: + - webpack.mix.js +css: true diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 8694c29..77008d5 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -14,11 +14,11 @@ class Kernel extends HttpKernel * @var array */ protected $middleware = [ + \App\Http\Middleware\TrustProxies::class, \App\Http\Middleware\CheckForMaintenanceMode::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, - \App\Http\Middleware\TrustProxies::class, ]; /** @@ -58,6 +58,7 @@ class Kernel extends HttpKernel 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, @@ -76,6 +77,7 @@ class Kernel extends HttpKernel \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\Authenticate::class, + \Illuminate\Routing\Middleware\ThrottleRequests::class, \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Auth\Middleware\Authorize::class, diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index 7daf51f..ee5b595 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -2,15 +2,15 @@ namespace App\Http\Middleware; -use Illuminate\Http\Request; use Fideloper\Proxy\TrustProxies as Middleware; +use Illuminate\Http\Request; class TrustProxies extends Middleware { /** * The trusted proxies for this application. * - * @var array + * @var array|string */ protected $proxies; diff --git a/app/Models/User.php b/app/Models/User.php index 933c2a2..66c771f 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -46,7 +46,7 @@ class User extends BaseModel implements * @var array */ protected $hidden = [ - 'password', 'remember_token', 'primary_role', + 'password', 'remember_token', 'email_verified_at', 'primary_role', ]; /** diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 0acc984..3049068 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Gate; class AuthServiceProvider extends ServiceProvider { diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 352cce4..395c518 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Broadcast; +use Illuminate\Support\ServiceProvider; class BroadcastServiceProvider extends ServiceProvider { diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index fca6152..e0bd583 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\Facades\Event; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Event; class EventServiceProvider extends ServiceProvider { @@ -13,9 +13,7 @@ class EventServiceProvider extends ServiceProvider * @var array */ protected $listen = [ - 'App\Events\Event' => [ - 'App\Listeners\EventListener', - ], + ]; /** diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 372811c..7a5823c 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { @@ -52,8 +52,7 @@ public function map() */ protected function mapWebRoutes() { - Route::prefix('web') - ->middleware('web') + Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); } @@ -67,7 +66,8 @@ protected function mapWebRoutes() */ protected function mapApiRoutes() { - Route::middleware('api') + Route::prefix('api') + ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); } diff --git a/composer.json b/composer.json index b671c1e..2d0b73e 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,12 @@ "fideloper/proxy": "^4.0", "laravel/framework": "^6", "laravel/tinker": "^1.0", - "specialtactics/l5-api": "^1", - "predis/predis": "^1.1" + "specialtactics/l5-api": "^1" }, "require-dev": { "barryvdh/laravel-ide-helper": "^2.4", "beyondcode/laravel-dump-server": "^1.0", - "filp/whoops": "^2.0", + "facade/ignition": "^1.4", "fzaninotto/faker": "^1.4", "laravel/telescope": "^2", "mockery/mockery": "^1.0", diff --git a/config/auth.php b/config/auth.php index 966d5ed..a999082 100644 --- a/config/auth.php +++ b/config/auth.php @@ -44,6 +44,7 @@ 'api' => [ 'driver' => 'jwt', 'provider' => 'users', + 'hash' => false, ], ], @@ -99,4 +100,17 @@ ], ], + /* + |-------------------------------------------------------------------------- + | Password Confirmation Timeout + |-------------------------------------------------------------------------- + | + | Here you may define the amount of seconds before a password confirmation + | times out and the user is prompted to re-enter their password via the + | confirmation screen. By default, the timeout lasts for three hours. + | + */ + + 'password_timeout' => 10800, + ]; diff --git a/config/broadcasting.php b/config/broadcasting.php index 3ca45ea..3bba110 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -37,7 +37,7 @@ 'app_id' => env('PUSHER_APP_ID'), 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), - 'encrypted' => true, + 'useTLS' => true, ], ], diff --git a/config/cache.php b/config/cache.php index 30f0cae..46751e6 100644 --- a/config/cache.php +++ b/config/cache.php @@ -82,6 +82,7 @@ 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'endpoint' => env('DYNAMODB_ENDPOINT'), ], ], diff --git a/config/database.php b/config/database.php index 49ec59a..199382d 100644 --- a/config/database.php +++ b/config/database.php @@ -1,5 +1,7 @@ [ 'driver' => 'sqlite', + 'url' => env('DATABASE_URL'), 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => '', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), @@ -42,6 +45,7 @@ 'mysql' => [ 'driver' => 'mysql', + 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), @@ -61,6 +65,7 @@ 'pgsql' => [ 'driver' => 'pgsql', + 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '5432'), 'database' => env('DB_DATABASE', 'forge'), @@ -75,6 +80,7 @@ 'sqlsrv' => [ 'driver' => 'sqlsrv', + 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '1433'), 'database' => env('DB_DATABASE', 'forge'), @@ -113,13 +119,15 @@ 'redis' => [ - 'client' => env('REDIS_CLIENT', 'predis'), + 'client' => env('REDIS_CLIENT', 'phpredis'), 'options' => [ - 'cluster' => env('REDIS_CLUSTER', 'predis'), + 'cluster' => env('REDIS_CLUSTER', 'redis'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), ], 'default' => [ + 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), @@ -127,6 +135,7 @@ ], 'cache' => [ + 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), diff --git a/config/filesystems.php b/config/filesystems.php index 77fa5de..ec6a7ce 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -37,7 +37,7 @@ | may even configure multiple disks of the same driver. Defaults have | been setup for each driver as an example of the required options. | - | Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace" + | Supported Drivers: "local", "ftp", "sftp", "s3" | */ diff --git a/config/logging.php b/config/logging.php index d09cd7d..0df8212 100644 --- a/config/logging.php +++ b/config/logging.php @@ -1,5 +1,6 @@ 'errorlog', 'level' => 'debug', ], + + 'null' => [ + 'driver' => 'monolog', + 'handler' => NullHandler::class, + ], ], ]; diff --git a/config/mail.php b/config/mail.php index 6f8469f..3c65eb3 100644 --- a/config/mail.php +++ b/config/mail.php @@ -11,8 +11,8 @@ | sending of e-mail. You may specify which one you're using throughout | your application here. By default, Laravel is setup for SMTP mail. | - | Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses", - | "sparkpost", "postmark", "log", "array" + | Supported: "smtp", "sendmail", "mailgun", "ses", + | "postmark", "log", "array" | */ diff --git a/config/queue.php b/config/queue.php index 07c7d2a..3a30d6c 100644 --- a/config/queue.php +++ b/config/queue.php @@ -80,6 +80,7 @@ */ 'failed' => [ + 'driver' => env('QUEUE_FAILED_DRIVER', 'database'), 'database' => env('DB_CONNECTION', 'mysql'), 'table' => 'failed_jobs', ], diff --git a/config/services.php b/config/services.php index f026b2c..2a1d616 100644 --- a/config/services.php +++ b/config/services.php @@ -8,9 +8,9 @@ |-------------------------------------------------------------------------- | | This file is for storing the credentials for third party services such - | as Stripe, Mailgun, SparkPost and others. This file provides a sane - | default location for this type of information, allowing packages - | to have a conventional place to find your various credentials. + | as Mailgun, Postmark, AWS and more. This file provides the de facto + | location for this type of information, allowing packages to have + | a conventional file to locate the various service credentials. | */ @@ -30,18 +30,4 @@ 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], - 'sparkpost' => [ - 'secret' => env('SPARKPOST_SECRET'), - ], - - 'stripe' => [ - 'model' => App\User::class, - 'key' => env('STRIPE_KEY'), - 'secret' => env('STRIPE_SECRET'), - 'webhook' => [ - 'secret' => env('STRIPE_WEBHOOK_SECRET'), - 'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300), - ], - ], - ]; diff --git a/database/.gitignore b/database/.gitignore index 9b1dffd..97fc976 100644 --- a/database/.gitignore +++ b/database/.gitignore @@ -1 +1,2 @@ *.sqlite +*.sqlite-journal diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 22ac9e3..084535f 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -1,6 +1,9 @@ define(App\Models\User::class, function (Faker $faker) { +$factory->define(User::class, function (Faker $faker) { return [ 'name' => $faker->name, 'email' => $faker->unique()->safeEmail, - 'password' => 'secret', - 'remember_token' => str_random(10), + 'email_verified_at' => now(), + 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password + 'remember_token' => Str::random(10), ]; }); diff --git a/database/migrations/2018_04_30_000010_create_users_table.php b/database/migrations/2018_04_30_000010_create_users_table.php index 399e0f9..640c41d 100644 --- a/database/migrations/2018_04_30_000010_create_users_table.php +++ b/database/migrations/2018_04_30_000010_create_users_table.php @@ -20,6 +20,7 @@ public function up() $table->string('name'); $table->string('email')->unique(); + $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->uuid('primary_role')->nullable(); diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php new file mode 100644 index 0000000..389bdf7 --- /dev/null +++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -0,0 +1,35 @@ +bigIncrements('id'); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('failed_jobs'); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 375b045..ecf0c6c 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -5,7 +5,7 @@ class DatabaseSeeder extends Seeder { /** - * Run the database seeds. + * Seed the application's database. * * @return void */ diff --git a/phpunit.xml b/phpunit.xml index 5f237af..7d83ad9 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -30,12 +30,12 @@ - - - - - - - + + + + + + + diff --git a/public/index.php b/public/index.php index e196467..4584cbc 100644 --- a/public/index.php +++ b/public/index.php @@ -3,8 +3,10 @@ /** * Laravel - A PHP Framework For Web Artisans * + * @package Laravel * @author Taylor Otwell */ + define('LARAVEL_START', microtime(true)); /* diff --git a/resources/lang/en/passwords.php b/resources/lang/en/passwords.php index bf6caf6..f3b01a4 100644 --- a/resources/lang/en/passwords.php +++ b/resources/lang/en/passwords.php @@ -13,7 +13,6 @@ | */ - 'password' => 'Passwords must be at least eight characters and match the confirmation.', 'reset' => 'Your password has been reset!', 'sent' => 'We have e-mailed your password reset link!', 'token' => 'This password reset token is invalid.', diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 8ab929c..ce1d80d 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -40,6 +40,7 @@ 'dimensions' => 'The :attribute has invalid image dimensions.', 'distinct' => 'The :attribute field has a duplicate value.', 'email' => 'The :attribute must be a valid email address.', + 'ends_with' => 'The :attribute must end with one of the following: :values', 'exists' => 'The selected :attribute is invalid.', 'file' => 'The :attribute must be a file.', 'filled' => 'The :attribute field must have a value.', @@ -92,6 +93,7 @@ 'not_in' => 'The selected :attribute is invalid.', 'not_regex' => 'The :attribute format is invalid.', 'numeric' => 'The :attribute must be a number.', + 'password' => 'The password is incorrect.', 'present' => 'The :attribute field must be present.', 'regex' => 'The :attribute format is invalid.', 'required' => 'The :attribute field is required.', diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php deleted file mode 100644 index 471513d..0000000 --- a/resources/views/welcome.blade.php +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - Laravel - - - - - - - - -
- @if (Route::has('login')) - - @endif - -
-
- Laravel -
- - -
-
- - diff --git a/routes/api.php b/routes/api.php index 387ad98..a1f58b6 100644 --- a/routes/api.php +++ b/routes/api.php @@ -13,10 +13,6 @@ | */ -Route::middleware('auth:api')->get('/user', function (Request $request) { - return $request->user(); -}); - /* * Welcome route - link to any public API documentation here */ diff --git a/server.php b/server.php index b07fa44..5fb6379 100644 --- a/server.php +++ b/server.php @@ -3,8 +3,10 @@ /** * Laravel - A PHP Framework For Web Artisans * + * @package Laravel * @author Taylor Otwell */ + $uri = urldecode( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ); diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index f31e495..cdb5111 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -2,8 +2,8 @@ namespace Tests\Feature; -use Tests\TestCase; use Illuminate\Foundation\Testing\RefreshDatabase; +use Tests\TestCase; class ExampleTest extends TestCase { diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index e9fe19c..266ef35 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -2,8 +2,8 @@ namespace Tests\Unit; -use Tests\TestCase; use Illuminate\Foundation\Testing\RefreshDatabase; +use Tests\TestCase; class ExampleTest extends TestCase { From 811b6ae1f5a0f3dd0b6a3befffe49c341e3531ab Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2019 22:07:54 +1100 Subject: [PATCH 04/12] Add redis pecl extension to docker setup --- env/docker/php-fpm/Dockerfile | 8 ++++++++ env/docker/workspace/Dockerfile | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/env/docker/php-fpm/Dockerfile b/env/docker/php-fpm/Dockerfile index 9552e05..76e446d 100644 --- a/env/docker/php-fpm/Dockerfile +++ b/env/docker/php-fpm/Dockerfile @@ -30,6 +30,14 @@ RUN docker-php-ext-install json && \ docker-php-ext-install bcmath && \ docker-php-ext-install sockets +# Install required PECL extensions +RUN pecl install \ + redis + +# Enable above +RUN docker-php-ext-enable \ + redis + ########################################################################### # xDebug: ########################################################################### diff --git a/env/docker/workspace/Dockerfile b/env/docker/workspace/Dockerfile index dcb6cad..0600788 100644 --- a/env/docker/workspace/Dockerfile +++ b/env/docker/workspace/Dockerfile @@ -42,6 +42,14 @@ RUN docker-php-ext-install json && \ docker-php-ext-install bcmath && \ docker-php-ext-install sockets +# Install required PECL extensions +RUN pecl install \ + redis + +# Enable above +RUN docker-php-ext-enable \ + redis + ########################################################################### # Laradock non-root user: ########################################################################### From 37fdf699393650be32883c5b6bd012adef9a6d14 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2019 22:28:59 +1100 Subject: [PATCH 05/12] StyleCI free plan has no support for multi-lang :( --- .styleci.yml | 34 ++++++++++++++-------------------- composer.json | 2 +- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/.styleci.yml b/.styleci.yml index 60e3989..88a9f02 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,20 +1,14 @@ -php: - preset: laravel - enabled: - - alpha_ordered_imports - disabled: - - length_ordered_imports - - unused_use - finder: - not-name: - - index.php - - server.php - exclude: - - "tests" - - "storage" - - "vendor" -js: - finder: - not-name: - - webpack.mix.js -css: true +preset: laravel +enabled: + - alpha_ordered_imports +disabled: + - length_ordered_imports + - unused_use +finder: + not-name: + - index.php + - server.php + exclude: + - "tests" + - "storage" + - "vendor" \ No newline at end of file diff --git a/composer.json b/composer.json index 2d0b73e..bfde5b9 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "fideloper/proxy": "^4.0", "laravel/framework": "^6", "laravel/tinker": "^1.0", - "specialtactics/l5-api": "^1" + "specialtactics/l5-api": "^1.1" }, "require-dev": { "barryvdh/laravel-ide-helper": "^2.4", From 5e7fe3af268efa01357293ea52ad827aa709ff4f Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2019 22:30:43 +1100 Subject: [PATCH 06/12] Include this exclude --- .styleci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.styleci.yml b/.styleci.yml index 88a9f02..9639f7c 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -4,6 +4,7 @@ enabled: disabled: - length_ordered_imports - unused_use + - post_increment finder: not-name: - index.php From 9dfdc817fc1ca1cec2c0d2a852a9e7206f082636 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2019 22:32:43 +1100 Subject: [PATCH 07/12] Add another exlude --- .styleci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.styleci.yml b/.styleci.yml index 9639f7c..ed2b71f 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -5,6 +5,7 @@ disabled: - length_ordered_imports - unused_use - post_increment + - phpdoc_summary finder: not-name: - index.php From 22de0c685fa76c7d2ca230f4ae3ae3a647d93a7b Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2019 22:40:55 +1100 Subject: [PATCH 08/12] Typehint dingo router so it's easy to use in routes file --- routes/api.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/routes/api.php b/routes/api.php index a1f58b6..27dbf2b 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,6 +1,7 @@ version('v1', ['middleware' => ['api']], function ($api) { +$api->version('v1', ['middleware' => ['api']], function (Router $api) { /* * Authentication */ - $api->group(['prefix' => 'auth'], function ($api) { - $api->group(['prefix' => 'jwt'], function ($api) { + $api->group(['prefix' => 'auth'], function (Router $api) { + $api->group(['prefix' => 'jwt'], function (Router $api) { $api->get('/token', 'App\Http\Controllers\Auth\AuthController@token'); }); }); @@ -37,12 +36,12 @@ /* * Authenticated routes */ - $api->group(['middleware' => ['api.auth']], function ($api) { + $api->group(['middleware' => ['api.auth']], function (Router $api) { /* * Authentication */ - $api->group(['prefix' => 'auth'], function ($api) { - $api->group(['prefix' => 'jwt'], function ($api) { + $api->group(['prefix' => 'auth'], function (Router $api) { + $api->group(['prefix' => 'jwt'], function (Router $api) { $api->get('/refresh', 'App\Http\Controllers\Auth\AuthController@refresh'); $api->delete('/token', 'App\Http\Controllers\Auth\AuthController@logout'); }); @@ -53,7 +52,7 @@ /* * Users */ - $api->group(['prefix' => 'users', 'middleware' => 'check_role:admin'], function ($api) { + $api->group(['prefix' => 'users', 'middleware' => 'check_role:admin'], function (Router $api) { $api->get('/', 'App\Http\Controllers\UserController@getAll'); $api->get('/{uuid}', 'App\Http\Controllers\UserController@get'); $api->post('/', 'App\Http\Controllers\UserController@post'); @@ -65,7 +64,7 @@ /* * Roles */ - $api->group(['prefix' => 'roles'], function ($api) { + $api->group(['prefix' => 'roles'], function (Router $api) { $api->get('/', 'App\Http\Controllers\RoleController@getAll'); }); }); From c82d936fb1384bf729ad936bf65dcfbf139e46a5 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2019 22:54:59 +1100 Subject: [PATCH 09/12] Fixing order of imports according to new style guide --- app/Models/User.php | 10 +++++----- .../2018_04_30_000010_create_users_table.php | 4 ++-- routes/api.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 66c771f..80dfd47 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,16 +2,16 @@ namespace App\Models; -use Illuminate\Notifications\Notifiable; +use App\Models\Role; +use Hash; use Illuminate\Auth\Authenticatable; use Illuminate\Auth\Passwords\CanResetPassword; -use Illuminate\Foundation\Auth\Access\Authorizable; -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; +use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; +use Illuminate\Foundation\Auth\Access\Authorizable; +use Illuminate\Notifications\Notifiable; use Tymon\JWTAuth\Contracts\JWTSubject; -use Hash; -use App\Models\Role; class User extends BaseModel implements AuthenticatableContract, diff --git a/database/migrations/2018_04_30_000010_create_users_table.php b/database/migrations/2018_04_30_000010_create_users_table.php index 640c41d..9765716 100644 --- a/database/migrations/2018_04_30_000010_create_users_table.php +++ b/database/migrations/2018_04_30_000010_create_users_table.php @@ -1,8 +1,8 @@ Date: Sun, 13 Oct 2019 23:04:34 +1100 Subject: [PATCH 10/12] More rearranging of use imports according to style --- app/Http/Controllers/Auth/AuthController.php | 4 ++-- app/Http/Controllers/Controller.php | 2 +- app/Http/Controllers/RoleController.php | 2 +- app/Providers/AppServiceProvider.php | 2 +- app/Providers/TelescopeServiceProvider.php | 2 +- config/telescope.php | 2 +- database/migrations/2018_04_30_000000_create_roles_table.php | 4 ++-- .../2018_04_30_000011_create_password_resets_table.php | 4 ++-- .../migrations/2018_04_30_000020_create_user_roles_table.php | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 3e50933..30d3b64 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -2,11 +2,11 @@ namespace App\Http\Controllers\Auth; -use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Models\User; -use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; +use Illuminate\Http\Request; use Specialtactics\L5Api\Http\Controllers\Features\JWTAuthenticationTrait; +use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; class AuthController extends Controller { diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 5289a7c..571bd55 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -2,9 +2,9 @@ namespace App\Http\Controllers; +use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; -use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Specialtactics\L5Api\Http\Controllers\RestfulController as BaseController; class Controller extends BaseController diff --git a/app/Http/Controllers/RoleController.php b/app/Http/Controllers/RoleController.php index 0956901..f078ce0 100644 --- a/app/Http/Controllers/RoleController.php +++ b/app/Http/Controllers/RoleController.php @@ -2,8 +2,8 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; use App\Models\Role; +use Illuminate\Http\Request; class RoleController extends Controller { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index fe23f5a..72c3913 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,9 +2,9 @@ namespace App\Providers; -use Illuminate\Support\ServiceProvider; use App\Exceptions\ApiExceptionHandler; use Config; +use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php index 945ba08..6d5b5dc 100644 --- a/app/Providers/TelescopeServiceProvider.php +++ b/app/Providers/TelescopeServiceProvider.php @@ -2,9 +2,9 @@ namespace App\Providers; -use Laravel\Telescope\Telescope; use Illuminate\Support\Facades\Gate; use Laravel\Telescope\IncomingEntry; +use Laravel\Telescope\Telescope; use Laravel\Telescope\TelescopeApplicationServiceProvider; class TelescopeServiceProvider extends TelescopeApplicationServiceProvider diff --git a/config/telescope.php b/config/telescope.php index 9cc039e..187e789 100644 --- a/config/telescope.php +++ b/config/telescope.php @@ -1,7 +1,7 @@ Date: Sun, 13 Oct 2019 23:08:30 +1100 Subject: [PATCH 11/12] Didn't catch this one (web route prefix) --- app/Providers/RouteServiceProvider.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 7a5823c..15d046c 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -39,8 +39,6 @@ public function map() $this->mapApiRoutes(); //$this->mapWebRoutes(); - - // } /** @@ -52,7 +50,8 @@ public function map() */ protected function mapWebRoutes() { - Route::middleware('web') + Route::prefix('web') + ->middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); } From b7079221c1d8a92f30f39ca5ca5665e49b088d93 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2019 23:09:55 +1100 Subject: [PATCH 12/12] And no prefix for api --- app/Providers/RouteServiceProvider.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 15d046c..7101879 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -65,8 +65,7 @@ protected function mapWebRoutes() */ protected function mapApiRoutes() { - Route::prefix('api') - ->middleware('api') + Route::middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); }