From e8e236c25ae45cfb3568ffa3e0810d3edbbc4fff Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:25 +0000 Subject: [PATCH 01/14] Remove default `app` files --- app/Console/Kernel.php | 27 -------------- app/Exceptions/Handler.php | 29 --------------- app/Http/Middleware/Authenticate.php | 17 --------- app/Http/Middleware/EncryptCookies.php | 16 -------- .../PreventRequestsDuringMaintenance.php | 16 -------- .../Middleware/RedirectIfAuthenticated.php | 28 -------------- app/Http/Middleware/TrimStrings.php | 19 ---------- app/Http/Middleware/TrustHosts.php | 20 ---------- app/Http/Middleware/TrustProxies.php | 28 -------------- app/Http/Middleware/ValidateSignature.php | 22 ----------- app/Http/Middleware/VerifyCsrfToken.php | 16 -------- app/Providers/AuthServiceProvider.php | 24 ------------ app/Providers/BroadcastServiceProvider.php | 19 ---------- app/Providers/EventServiceProvider.php | 37 ------------------- 14 files changed, 318 deletions(-) delete mode 100644 app/Console/Kernel.php delete mode 100644 app/Exceptions/Handler.php delete mode 100644 app/Http/Middleware/Authenticate.php delete mode 100644 app/Http/Middleware/EncryptCookies.php delete mode 100644 app/Http/Middleware/PreventRequestsDuringMaintenance.php delete mode 100644 app/Http/Middleware/RedirectIfAuthenticated.php delete mode 100644 app/Http/Middleware/TrimStrings.php delete mode 100644 app/Http/Middleware/TrustHosts.php delete mode 100644 app/Http/Middleware/TrustProxies.php delete mode 100644 app/Http/Middleware/ValidateSignature.php delete mode 100644 app/Http/Middleware/VerifyCsrfToken.php delete mode 100644 app/Providers/AuthServiceProvider.php delete mode 100644 app/Providers/BroadcastServiceProvider.php delete mode 100644 app/Providers/EventServiceProvider.php diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php deleted file mode 100644 index e6b9960..0000000 --- a/app/Console/Kernel.php +++ /dev/null @@ -1,27 +0,0 @@ -command('inspire')->hourly(); - } - - /** - * Register the commands for the application. - */ - protected function commands(): void - { - $this->load(__DIR__.'/Commands'); - - require base_path('routes/console.php'); - } -} diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php deleted file mode 100644 index 80958d6..0000000 --- a/app/Exceptions/Handler.php +++ /dev/null @@ -1,29 +0,0 @@ -reportable(function (Throwable $e) { - }); - } -} diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php deleted file mode 100644 index d4ef644..0000000 --- a/app/Http/Middleware/Authenticate.php +++ /dev/null @@ -1,17 +0,0 @@ -expectsJson() ? null : route('login'); - } -} diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php deleted file mode 100644 index 50d0fe7..0000000 --- a/app/Http/Middleware/EncryptCookies.php +++ /dev/null @@ -1,16 +0,0 @@ -check()) { - return redirect(RouteServiceProvider::HOME); - } - } - - return $next($request); - } -} diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php deleted file mode 100644 index 88cadca..0000000 --- a/app/Http/Middleware/TrimStrings.php +++ /dev/null @@ -1,19 +0,0 @@ - - */ - protected $except = [ - 'current_password', - 'password', - 'password_confirmation', - ]; -} diff --git a/app/Http/Middleware/TrustHosts.php b/app/Http/Middleware/TrustHosts.php deleted file mode 100644 index c9c58bd..0000000 --- a/app/Http/Middleware/TrustHosts.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ - public function hosts(): array - { - return [ - $this->allSubdomainsOfApplicationUrl(), - ]; - } -} diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php deleted file mode 100644 index 3391630..0000000 --- a/app/Http/Middleware/TrustProxies.php +++ /dev/null @@ -1,28 +0,0 @@ -|string|null - */ - protected $proxies; - - /** - * The headers that should be used to detect proxies. - * - * @var int - */ - protected $headers = - Request::HEADER_X_FORWARDED_FOR | - Request::HEADER_X_FORWARDED_HOST | - Request::HEADER_X_FORWARDED_PORT | - Request::HEADER_X_FORWARDED_PROTO | - Request::HEADER_X_FORWARDED_AWS_ELB; -} diff --git a/app/Http/Middleware/ValidateSignature.php b/app/Http/Middleware/ValidateSignature.php deleted file mode 100644 index 093bf64..0000000 --- a/app/Http/Middleware/ValidateSignature.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ - protected $except = [ - // 'fbclid', - // 'utm_campaign', - // 'utm_content', - // 'utm_medium', - // 'utm_source', - // 'utm_term', - ]; -} diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php deleted file mode 100644 index 4c029cf..0000000 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ /dev/null @@ -1,16 +0,0 @@ - 'App\Policies\ModelPolicy', - ]; - - /** - * Register any authentication / authorization services. - */ - public function boot(): void - { - } -} diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php deleted file mode 100644 index 2be04f5..0000000 --- a/app/Providers/BroadcastServiceProvider.php +++ /dev/null @@ -1,19 +0,0 @@ - [ - SendEmailVerificationNotification::class, - ], - ]; - - /** - * Register any events for your application. - */ - public function boot(): void - { - } - - /** - * Determine if events and listeners should be automatically discovered. - */ - public function shouldDiscoverEvents(): bool - { - return false; - } -} From cc75635fefaa8d7bf99c2026e9d135cf6e2c3657 Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:27 +0000 Subject: [PATCH 02/14] Shift core files --- artisan | 50 ++++++------------------------------------------ public/index.php | 48 +++++----------------------------------------- 2 files changed, 11 insertions(+), 87 deletions(-) diff --git a/artisan b/artisan index 67a3329..8e04b42 100755 --- a/artisan +++ b/artisan @@ -1,53 +1,15 @@ #!/usr/bin/env php make(Illuminate\Contracts\Console\Kernel::class); - -$status = $kernel->handle( - $input = new Symfony\Component\Console\Input\ArgvInput, - new Symfony\Component\Console\Output\ConsoleOutput -); - -/* -|-------------------------------------------------------------------------- -| Shutdown The Application -|-------------------------------------------------------------------------- -| -| Once Artisan has finished running, we will fire off the shutdown events -| so that any final work may be done by the application before we shut -| down the process. This is the last thing to happen to the request. -| -*/ - -$kernel->terminate($input, $status); +// Bootstrap Laravel and handle the command... +$status = (require_once __DIR__.'/bootstrap/app.php') + ->handleCommand(new ArgvInput); exit($status); diff --git a/public/index.php b/public/index.php index 1d69f3a..947d989 100644 --- a/public/index.php +++ b/public/index.php @@ -1,55 +1,17 @@ make(Kernel::class); - -$response = $kernel->handle( - $request = Request::capture() -)->send(); - -$kernel->terminate($request, $response); +// Bootstrap Laravel and handle the request... +(require_once __DIR__.'/../bootstrap/app.php') + ->handleRequest(Request::capture()); From 9a4d5d4891a1a9451c80b70767f942c8c3e80d23 Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:34 +0000 Subject: [PATCH 03/14] Streamline config files --- config/.gitkeep | 0 config/app.php | 163 ------------------------------- config/auth.php | 106 -------------------- config/broadcasting.php | 67 ------------- config/cache.php | 107 -------------------- config/cors.php | 32 ------ config/database.php | 141 +-------------------------- config/filesystems.php | 72 -------------- config/hashing.php | 52 ---------- config/logging.php | 129 ------------------------ config/mail.php | 110 --------------------- config/queue.php | 89 ----------------- config/services.php | 20 ---- config/session.php | 211 ---------------------------------------- config/view.php | 34 ------- 15 files changed, 3 insertions(+), 1330 deletions(-) create mode 100644 config/.gitkeep delete mode 100644 config/broadcasting.php delete mode 100644 config/cache.php delete mode 100644 config/cors.php delete mode 100644 config/filesystems.php delete mode 100644 config/hashing.php delete mode 100644 config/logging.php delete mode 100644 config/queue.php delete mode 100644 config/session.php delete mode 100644 config/view.php diff --git a/config/.gitkeep b/config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/config/app.php b/config/app.php index ccff52b..a14dd79 100644 --- a/config/app.php +++ b/config/app.php @@ -4,155 +4,6 @@ use Illuminate\Support\ServiceProvider; return [ - /* - |-------------------------------------------------------------------------- - | Application Name - |-------------------------------------------------------------------------- - | - | This value is the name of your application. This value is used when the - | framework needs to place the application's name in a notification or - | any other location as required by the application or its packages. - | - */ - - 'name' => env('APP_NAME', 'Laravel'), - - /* - |-------------------------------------------------------------------------- - | Application Environment - |-------------------------------------------------------------------------- - | - | This value determines the "environment" your application is currently - | running in. This may determine how you prefer to configure various - | services the application utilizes. Set this in your ".env" file. - | - */ - - 'env' => env('APP_ENV', 'production'), - - /* - |-------------------------------------------------------------------------- - | Application Debug Mode - |-------------------------------------------------------------------------- - | - | When your application is in debug mode, detailed error messages with - | stack traces will be shown on every error that occurs within your - | application. If disabled, a simple generic error page is shown. - | - */ - - 'debug' => (bool) env('APP_DEBUG', false), - - /* - |-------------------------------------------------------------------------- - | Application URL - |-------------------------------------------------------------------------- - | - | This URL is used by the console to properly generate URLs when using - | the Artisan command line tool. You should set this to the root of - | your application so that it is used when running Artisan tasks. - | - */ - - 'url' => env('APP_URL', 'http://localhost'), - - 'asset_url' => env('ASSET_URL', null), - - /* - |-------------------------------------------------------------------------- - | Application Timezone - |-------------------------------------------------------------------------- - | - | Here you may specify the default timezone for your application, which - | will be used by the PHP date and date-time functions. We have gone - | ahead and set this to a sensible default for you out of the box. - | - */ - - 'timezone' => 'UTC', - - /* - |-------------------------------------------------------------------------- - | Application Locale Configuration - |-------------------------------------------------------------------------- - | - | The application locale determines the default locale that will be used - | by the translation service provider. You are free to set this value - | to any of the locales which will be supported by the application. - | - */ - - 'locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Application Fallback Locale - |-------------------------------------------------------------------------- - | - | The fallback locale determines the locale to use when the current one - | is not available. You may change the value to correspond to any of - | the language folders that are provided through your application. - | - */ - - 'fallback_locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Faker Locale - |-------------------------------------------------------------------------- - | - | This locale will be used by the Faker PHP library when generating fake - | data for your database seeds. For example, this will be used to get - | localized telephone numbers, street address information and more. - | - */ - - 'faker_locale' => 'en_US', - - /* - |-------------------------------------------------------------------------- - | Encryption Key - |-------------------------------------------------------------------------- - | - | This key is used by the Illuminate encrypter service and should be set - | to a random, 32 character string, otherwise these encrypted strings - | will not be safe. Please do this before deploying an application! - | - */ - - 'key' => env('APP_KEY'), - - 'cipher' => 'AES-256-CBC', - - /* - |-------------------------------------------------------------------------- - | Maintenance Mode Driver - |-------------------------------------------------------------------------- - | - | These configuration options determine the driver used to determine and - | manage Laravel's "maintenance mode" status. The "cache" driver will - | allow maintenance mode to be controlled across multiple machines. - | - | Supported drivers: "file", "cache" - | - */ - - 'maintenance' => [ - 'driver' => 'file', - // 'store' => 'redis', - ], - - /* - |-------------------------------------------------------------------------- - | Autoloaded Service Providers - |-------------------------------------------------------------------------- - | - | The service providers listed here will be automatically loaded on the - | request to your application. Feel free to add your own services to - | this array to grant expanded functionality to your applications. - | - */ 'providers' => ServiceProvider::defaultProviders()->merge([ /* @@ -169,18 +20,4 @@ App\Providers\RouteServiceProvider::class, ])->toArray(), - /* - |-------------------------------------------------------------------------- - | Class Aliases - |-------------------------------------------------------------------------- - | - | This array of class aliases will be registered when this application - | is started. However, feel free to register as many as you wish as - | the aliases are "lazy" loaded so they don't hinder performance. - | - */ - - 'aliases' => Facade::defaultAliases()->merge([ - // ... - ])->toArray(), ]; diff --git a/config/auth.php b/config/auth.php index 50be1a2..1642fb2 100644 --- a/config/auth.php +++ b/config/auth.php @@ -1,45 +1,8 @@ [ - 'guard' => 'web', - 'passwords' => 'users', - ], - - /* - |-------------------------------------------------------------------------- - | Authentication Guards - |-------------------------------------------------------------------------- - | - | Next, you may define every authentication guard for your application. - | Of course, a great default configuration has been defined for you - | here which uses session storage and the Eloquent user provider. - | - | All authentication drivers have a user provider. This defines how the - | users are actually retrieved out of your database or other storage - | mechanisms used by this application to persist your user's data. - | - | Supported: "session" - | - */ 'guards' => [ - 'web' => [ - 'driver' => 'session', - 'provider' => 'users', - ], - 'api' => [ 'driver' => 'token', 'provider' => 'users', @@ -47,73 +10,4 @@ ], ], - /* - |-------------------------------------------------------------------------- - | User Providers - |-------------------------------------------------------------------------- - | - | All authentication drivers have a user provider. This defines how the - | users are actually retrieved out of your database or other storage - | mechanisms used by this application to persist your user's data. - | - | If you have multiple user tables or models you may configure multiple - | sources which represent each model / table. These sources may then - | be assigned to any extra authentication guards you have defined. - | - | Supported: "database", "eloquent" - | - */ - - 'providers' => [ - 'users' => [ - 'driver' => 'eloquent', - 'model' => App\Models\User::class, - ], - - // 'users' => [ - // 'driver' => 'database', - // 'table' => 'users', - // ], - ], - - /* - |-------------------------------------------------------------------------- - | Resetting Passwords - |-------------------------------------------------------------------------- - | - | You may specify multiple password reset configurations if you have more - | than one user table or model in the application and you want to have - | separate password reset settings based on the specific user types. - | - | The expiry time is the number of minutes that each reset token will be - | considered valid. This security feature keeps tokens short-lived so - | they have less time to be guessed. You may change this as needed. - | - | The throttle setting is the number of seconds a user must wait before - | generating more password reset tokens. This prevents the user from - | quickly generating a very large amount of password reset tokens. - | - */ - - 'passwords' => [ - 'users' => [ - 'provider' => 'users', - 'table' => 'password_resets', - 'expire' => 60, - 'throttle' => 60, - ], - ], - - /* - |-------------------------------------------------------------------------- - | 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 deleted file mode 100644 index 7be819c..0000000 --- a/config/broadcasting.php +++ /dev/null @@ -1,67 +0,0 @@ - env('BROADCAST_DRIVER', 'null'), - - /* - |-------------------------------------------------------------------------- - | Broadcast Connections - |-------------------------------------------------------------------------- - | - | Here you may define all of the broadcast connections that will be used - | to broadcast events to other systems or over websockets. Samples of - | each available type of connection are provided inside this array. - | - */ - - 'connections' => [ - 'pusher' => [ - 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'secret' => env('PUSHER_APP_SECRET'), - 'app_id' => env('PUSHER_APP_ID'), - 'options' => [ - 'cluster' => env('PUSHER_APP_CLUSTER'), - 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', - 'port' => env('PUSHER_PORT', 443), - 'scheme' => env('PUSHER_SCHEME', 'https'), - 'encrypted' => true, - 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', - ], - 'client_options' => [ - // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html - ], - ], - - 'ably' => [ - 'driver' => 'ably', - 'key' => env('ABLY_KEY'), - ], - - 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', - ], - - 'log' => [ - 'driver' => 'log', - ], - - 'null' => [ - 'driver' => 'null', - ], - ], -]; diff --git a/config/cache.php b/config/cache.php deleted file mode 100644 index 6fc64ca..0000000 --- a/config/cache.php +++ /dev/null @@ -1,107 +0,0 @@ - env('CACHE_DRIVER', 'file'), - - /* - |-------------------------------------------------------------------------- - | Cache Stores - |-------------------------------------------------------------------------- - | - | Here you may define all of the cache "stores" for your application as - | well as their drivers. You may even define multiple stores for the - | same cache driver to group types of items stored in your caches. - | - | Supported drivers: "apc", "array", "database", "file", - | "memcached", "redis", "dynamodb", "octane", "null" - | - */ - - 'stores' => [ - 'apc' => [ - 'driver' => 'apc', - ], - - 'array' => [ - 'driver' => 'array', - 'serialize' => false, - ], - - 'database' => [ - 'driver' => 'database', - 'table' => 'cache', - 'connection' => null, - 'lock_connection' => null, - ], - - 'file' => [ - 'driver' => 'file', - 'path' => storage_path('framework/cache/data'), - 'lock_path' => storage_path('framework/cache/data'), - ], - - 'memcached' => [ - 'driver' => 'memcached', - 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), - 'sasl' => [ - env('MEMCACHED_USERNAME'), - env('MEMCACHED_PASSWORD'), - ], - 'options' => [ - // Memcached::OPT_CONNECT_TIMEOUT => 2000, - ], - 'servers' => [ - [ - 'host' => env('MEMCACHED_HOST', '127.0.0.1'), - 'port' => env('MEMCACHED_PORT', 11211), - 'weight' => 100, - ], - ], - ], - - 'redis' => [ - 'driver' => 'redis', - 'connection' => 'cache', - 'lock_connection' => 'default', - ], - - 'dynamodb' => [ - 'driver' => 'dynamodb', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), - 'endpoint' => env('DYNAMODB_ENDPOINT'), - ], - - 'octane' => [ - 'driver' => 'octane', - ], - ], - - /* - |-------------------------------------------------------------------------- - | Cache Key Prefix - |-------------------------------------------------------------------------- - | - | When utilizing the APC, database, memcached, Redis, or DynamoDB cache - | stores there might be other applications using the same cache. For - | that reason, you may prefix every cache key to avoid collisions. - | - */ - - 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), -]; diff --git a/config/cors.php b/config/cors.php deleted file mode 100644 index 866c807..0000000 --- a/config/cors.php +++ /dev/null @@ -1,32 +0,0 @@ - ['api/*'], - - 'allowed_methods' => ['*'], - - 'allowed_origins' => ['*'], - - 'allowed_origins_patterns' => [], - - 'allowed_headers' => ['*'], - - 'exposed_headers' => [], - - 'max_age' => 0, - - 'supports_credentials' => false, -]; diff --git a/config/database.php b/config/database.php index 8d7383c..1fc8066 100644 --- a/config/database.php +++ b/config/database.php @@ -1,145 +1,10 @@ env('DB_CONNECTION', 'mysql'), - - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | - */ - - 'connections' => [ - 'sqlite' => [ - 'driver' => 'sqlite', - 'url' => env('DATABASE_URL'), - 'database' => env('DB_DATABASE', database_path('database.sqlite')), - 'prefix' => '', - 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), - ], - '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'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'prefix_indexes' => true, - 'strict' => true, - 'engine' => null, - 'options' => extension_loaded('pdo_mysql') ? array_filter([ - PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), - ]) : [], - ], - - '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'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'prefix_indexes' => true, - 'search_path' => 'public', - 'sslmode' => 'prefer', - ], - - 'sqlsrv' => [ - 'driver' => 'sqlsrv', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', 'localhost'), - 'port' => env('DB_PORT', '1433'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'prefix_indexes' => true, - // 'encrypt' => env('DB_ENCRYPT', 'yes'), - // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), - ], + 'migrations' => [ + 'table' => 'migrations', + 'update_date_on_publish' => false, // disable to preserve original behavior for existing applications ], - /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. - | - */ - - 'migrations' => 'migrations', - - /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store that also - | provides a richer body of commands than a typical key-value system - | such as APC or Memcached. Laravel makes it easy to dig right in. - | - */ - - 'redis' => [ - 'client' => env('REDIS_CLIENT', 'phpredis'), - - 'options' => [ - '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'), - 'username' => env('REDIS_USERNAME'), - 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'database' => env('REDIS_DB', '0'), - ], - - 'cache' => [ - 'url' => env('REDIS_URL'), - 'host' => env('REDIS_HOST', '127.0.0.1'), - 'username' => env('REDIS_USERNAME'), - 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'database' => env('REDIS_CACHE_DB', '1'), - ], - ], ]; diff --git a/config/filesystems.php b/config/filesystems.php deleted file mode 100644 index 17e53fc..0000000 --- a/config/filesystems.php +++ /dev/null @@ -1,72 +0,0 @@ - env('FILESYSTEM_DISK', 'local'), - - /* - |-------------------------------------------------------------------------- - | Filesystem Disks - |-------------------------------------------------------------------------- - | - | Here you may configure as many filesystem "disks" as you wish, and you - | may even configure multiple disks of the same driver. Defaults have - | been set up for each driver as an example of the required values. - | - | Supported Drivers: "local", "ftp", "sftp", "s3" - | - */ - - 'disks' => [ - 'local' => [ - 'driver' => 'local', - 'root' => storage_path('app'), - 'throw' => false, - ], - - 'public' => [ - 'driver' => 'local', - 'root' => storage_path('app/public'), - 'url' => env('APP_URL').'/storage', - 'visibility' => 'public', - 'throw' => false, - ], - - 's3' => [ - 'driver' => 's3', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION'), - 'bucket' => env('AWS_BUCKET'), - 'url' => env('AWS_URL'), - 'endpoint' => env('AWS_ENDPOINT'), - 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), - 'throw' => false, - ], - ], - - /* - |-------------------------------------------------------------------------- - | Symbolic Links - |-------------------------------------------------------------------------- - | - | Here you may configure the symbolic links that will be created when the - | `storage:link` Artisan command is executed. The array keys should be - | the locations of the links and the values should be their targets. - | - */ - - 'links' => [ - public_path('storage') => storage_path('app/public'), - ], -]; diff --git a/config/hashing.php b/config/hashing.php deleted file mode 100644 index 189c5ea..0000000 --- a/config/hashing.php +++ /dev/null @@ -1,52 +0,0 @@ - 'bcrypt', - - /* - |-------------------------------------------------------------------------- - | Bcrypt Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Bcrypt algorithm. This will allow you - | to control the amount of time it takes to hash the given password. - | - */ - - 'bcrypt' => [ - 'rounds' => env('BCRYPT_ROUNDS', 12), - 'verify' => true, - ], - - /* - |-------------------------------------------------------------------------- - | Argon Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Argon algorithm. These will allow you - | to control the amount of time it takes to hash the given password. - | - */ - - 'argon' => [ - 'memory' => 1024, - 'threads' => 2, - 'time' => 2, - 'verify' => true, - ], -]; diff --git a/config/logging.php b/config/logging.php deleted file mode 100644 index afed6a9..0000000 --- a/config/logging.php +++ /dev/null @@ -1,129 +0,0 @@ - env('LOG_CHANNEL', 'stack'), - - /* - |-------------------------------------------------------------------------- - | Deprecations Log Channel - |-------------------------------------------------------------------------- - | - | This option controls the log channel that should be used to log warnings - | regarding deprecated PHP and library features. This allows you to get - | your application ready for upcoming major versions of dependencies. - | - */ - - 'deprecations' => [ - 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), - 'trace' => false, - ], - - /* - |-------------------------------------------------------------------------- - | Log Channels - |-------------------------------------------------------------------------- - | - | Here you may configure the log channels for your application. Out of - | the box, Laravel uses the Monolog PHP logging library. This gives - | you a variety of powerful log handlers / formatters to utilize. - | - | Available Drivers: "single", "daily", "slack", "syslog", - | "errorlog", "monolog", - | "custom", "stack" - | - */ - - 'channels' => [ - 'stack' => [ - 'driver' => 'stack', - 'channels' => ['single'], - 'ignore_exceptions' => false, - ], - - 'single' => [ - 'driver' => 'single', - 'path' => storage_path('logs/laravel.log'), - 'level' => env('LOG_LEVEL', 'debug'), - 'replace_placeholders' => true, - ], - - 'daily' => [ - 'driver' => 'daily', - 'path' => storage_path('logs/laravel.log'), - 'level' => env('LOG_LEVEL', 'debug'), - 'days' => 14, - 'replace_placeholders' => true, - ], - - 'slack' => [ - 'driver' => 'slack', - 'url' => env('LOG_SLACK_WEBHOOK_URL'), - 'username' => 'Laravel Log', - 'emoji' => ':boom:', - 'level' => env('LOG_LEVEL', 'critical'), - 'replace_placeholders' => true, - ], - - 'papertrail' => [ - 'driver' => 'monolog', - 'level' => env('LOG_LEVEL', 'debug'), - 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), - 'handler_with' => [ - 'host' => env('PAPERTRAIL_URL'), - 'port' => env('PAPERTRAIL_PORT'), - 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), - ], - 'processors' => [PsrLogMessageProcessor::class], - ], - - 'stderr' => [ - 'driver' => 'monolog', - 'level' => env('LOG_LEVEL', 'debug'), - 'handler' => StreamHandler::class, - 'formatter' => env('LOG_STDERR_FORMATTER'), - 'with' => [ - 'stream' => 'php://stderr', - ], - 'processors' => [PsrLogMessageProcessor::class], - ], - - 'syslog' => [ - 'driver' => 'syslog', - 'level' => env('LOG_LEVEL', 'debug'), - 'facility' => LOG_USER, - 'replace_placeholders' => true, - ], - - 'errorlog' => [ - 'driver' => 'errorlog', - 'level' => env('LOG_LEVEL', 'debug'), - 'replace_placeholders' => true, - ], - - 'null' => [ - 'driver' => 'monolog', - 'handler' => NullHandler::class, - ], - - 'emergency' => [ - 'path' => storage_path('logs/laravel.log'), - ], - ], -]; diff --git a/config/mail.php b/config/mail.php index a072972..f88455f 100644 --- a/config/mail.php +++ b/config/mail.php @@ -1,62 +1,8 @@ env('MAIL_MAILER', 'smtp'), - - /* - |-------------------------------------------------------------------------- - | Mailer Configurations - |-------------------------------------------------------------------------- - | - | Here you may configure all of the mailers used by your application plus - | their respective settings. Several examples have been configured for - | you and you are free to add your own as your application requires. - | - | Laravel supports a variety of mail "transport" drivers to be used while - | sending an e-mail. You will specify which one you are using for your - | mailers below. You are free to add additional mailers as required. - | - | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", - | "postmark", "log", "array", "failover", "roundrobin" - | - */ 'mailers' => [ - 'smtp' => [ - 'transport' => 'smtp', - 'url' => env('MAIL_URL'), - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - 'port' => env('MAIL_PORT', 587), - 'encryption' => env('MAIL_ENCRYPTION', 'tls'), - 'username' => env('MAIL_USERNAME'), - 'password' => env('MAIL_PASSWORD'), - 'timeout' => null, - 'local_domain' => env('MAIL_EHLO_DOMAIN'), - ], - - 'ses' => [ - 'transport' => 'ses', - ], - - 'postmark' => [ - 'transport' => 'postmark', - // 'message_stream_id' => null, - // 'client' => [ - // 'timeout' => 5, - // ], - ], - 'mailgun' => [ 'transport' => 'mailgun', // 'client' => [ @@ -64,28 +10,6 @@ // ], ], - 'sendmail' => [ - 'transport' => 'sendmail', - 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), - ], - - 'log' => [ - 'transport' => 'log', - 'channel' => env('MAIL_LOG_CHANNEL'), - ], - - 'array' => [ - 'transport' => 'array', - ], - - 'failover' => [ - 'transport' => 'failover', - 'mailers' => [ - 'smtp', - 'log', - ], - ], - 'roundrobin' => [ 'transport' => 'roundrobin', 'mailers' => [ @@ -95,38 +19,4 @@ ], ], - /* - |-------------------------------------------------------------------------- - | Global "From" Address - |-------------------------------------------------------------------------- - | - | You may wish for all e-mails sent by your application to be sent from - | the same address. Here, you may specify a name and address that is - | used globally for all e-mails that are sent by your application. - | - */ - - 'from' => [ - 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), - 'name' => env('MAIL_FROM_NAME', 'Example'), - ], - - /* - |-------------------------------------------------------------------------- - | Markdown Mail Settings - |-------------------------------------------------------------------------- - | - | If you are using Markdown based email rendering, you may configure your - | theme and component paths here, allowing you to customize the design - | of the emails. Or, you may simply stick with the Laravel defaults! - | - */ - - 'markdown' => [ - 'theme' => 'default', - - 'paths' => [ - resource_path('views/vendor/mail'), - ], - ], ]; diff --git a/config/queue.php b/config/queue.php deleted file mode 100644 index 2b8b9b9..0000000 --- a/config/queue.php +++ /dev/null @@ -1,89 +0,0 @@ - env('QUEUE_CONNECTION', 'sync'), - - /* - |-------------------------------------------------------------------------- - | Queue Connections - |-------------------------------------------------------------------------- - | - | Here you may configure the connection information for each server that - | is used by your application. A default configuration has been added - | for each back-end shipped with Laravel. You are free to add more. - | - | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" - | - */ - - 'connections' => [ - 'sync' => [ - 'driver' => 'sync', - ], - - 'database' => [ - 'driver' => 'database', - 'table' => 'jobs', - 'queue' => 'default', - 'retry_after' => 90, - 'after_commit' => false, - ], - - 'beanstalkd' => [ - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, - 'block_for' => 0, - 'after_commit' => false, - ], - - 'sqs' => [ - 'driver' => 'sqs', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), - 'queue' => env('SQS_QUEUE', 'default'), - 'suffix' => env('SQS_SUFFIX'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'after_commit' => false, - ], - - 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', - 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 90, - 'block_for' => null, - 'after_commit' => false, - ], - ], - - /* - |-------------------------------------------------------------------------- - | Failed Queue Jobs - |-------------------------------------------------------------------------- - | - | These options configure the behavior of failed queue job logging so you - | can control which database and table are used to store the jobs that - | have failed. You may change them to any database / table you wish. - | - */ - - 'failed' => [ - 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), - 'database' => env('DB_CONNECTION', 'mysql'), - 'table' => 'failed_jobs', - ], -]; diff --git a/config/services.php b/config/services.php index 5cc6e06..62e0a08 100644 --- a/config/services.php +++ b/config/services.php @@ -1,17 +1,6 @@ [ 'domain' => env('MAILGUN_DOMAIN'), @@ -20,13 +9,4 @@ 'scheme' => 'https', ], - 'postmark' => [ - 'token' => env('POSTMARK_TOKEN'), - ], - - 'ses' => [ - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - ], ]; diff --git a/config/session.php b/config/session.php deleted file mode 100644 index 07d8668..0000000 --- a/config/session.php +++ /dev/null @@ -1,211 +0,0 @@ - env('SESSION_DRIVER', 'file'), - - /* - |-------------------------------------------------------------------------- - | Session Lifetime - |-------------------------------------------------------------------------- - | - | Here you may specify the number of minutes that you wish the session - | to be allowed to remain idle before it expires. If you want them - | to immediately expire on the browser closing, set that option. - | - */ - - 'lifetime' => env('SESSION_LIFETIME', 120), - - 'expire_on_close' => false, - - /* - |-------------------------------------------------------------------------- - | Session Encryption - |-------------------------------------------------------------------------- - | - | This option allows you to easily specify that all of your session data - | should be encrypted before it is stored. All encryption will be run - | automatically by Laravel and you can use the Session like normal. - | - */ - - 'encrypt' => false, - - /* - |-------------------------------------------------------------------------- - | Session File Location - |-------------------------------------------------------------------------- - | - | When using the native session driver, we need a location where session - | files may be stored. A default has been set for you but a different - | location may be specified. This is only needed for file sessions. - | - */ - - 'files' => storage_path('framework/sessions'), - - /* - |-------------------------------------------------------------------------- - | Session Database Connection - |-------------------------------------------------------------------------- - | - | When using the "database" or "redis" session drivers, you may specify a - | connection that should be used to manage these sessions. This should - | correspond to a connection in your database configuration options. - | - */ - - 'connection' => env('SESSION_CONNECTION'), - - /* - |-------------------------------------------------------------------------- - | Session Database Table - |-------------------------------------------------------------------------- - | - | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of course, a sensible default is - | provided for you; however, you are free to change this as needed. - | - */ - - 'table' => 'sessions', - - /* - |-------------------------------------------------------------------------- - | Session Cache Store - |-------------------------------------------------------------------------- - | - | While using one of the framework's cache driven session backends you may - | list a cache store that should be used for these sessions. This value - | must match with one of the application's configured cache "stores". - | - | Affects: "apc", "dynamodb", "memcached", "redis" - | - */ - - 'store' => env('SESSION_STORE'), - - /* - |-------------------------------------------------------------------------- - | Session Sweeping Lottery - |-------------------------------------------------------------------------- - | - | Some session drivers must manually sweep their storage location to get - | rid of old sessions from storage. Here are the chances that it will - | happen on a given request. By default, the odds are 2 out of 100. - | - */ - - 'lottery' => [2, 100], - - /* - |-------------------------------------------------------------------------- - | Session Cookie Name - |-------------------------------------------------------------------------- - | - | Here you may change the name of the cookie used to identify a session - | instance by ID. The name specified here will get used every time a - | new session cookie is created by the framework for every driver. - | - */ - - 'cookie' => env( - 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'laravel'), '_').'_session' - ), - - /* - |-------------------------------------------------------------------------- - | Session Cookie Path - |-------------------------------------------------------------------------- - | - | The session cookie path determines the path for which the cookie will - | be regarded as available. Typically, this will be the root path of - | your application but you are free to change this when necessary. - | - */ - - 'path' => '/', - - /* - |-------------------------------------------------------------------------- - | Session Cookie Domain - |-------------------------------------------------------------------------- - | - | Here you may change the domain of the cookie used to identify a session - | in your application. This will determine which domains the cookie is - | available to in your application. A sensible default has been set. - | - */ - - 'domain' => env('SESSION_DOMAIN'), - - /* - |-------------------------------------------------------------------------- - | HTTPS Only Cookies - |-------------------------------------------------------------------------- - | - | By setting this option to true, session cookies will only be sent back - | to the server if the browser has a HTTPS connection. This will keep - | the cookie from being sent to you when it can't be done securely. - | - */ - - 'secure' => env('SESSION_SECURE_COOKIE'), - - /* - |-------------------------------------------------------------------------- - | HTTP Access Only - |-------------------------------------------------------------------------- - | - | Setting this value to true will prevent JavaScript from accessing the - | value of the cookie and the cookie will only be accessible through - | the HTTP protocol. You are free to modify this option if needed. - | - */ - - 'http_only' => true, - - /* - |-------------------------------------------------------------------------- - | Same-Site Cookies - |-------------------------------------------------------------------------- - | - | This option determines how your cookies behave when cross-site requests - | take place, and can be used to mitigate CSRF attacks. By default, we - | will set this value to "lax" since this is a secure default value. - | - | Supported: "lax", "strict", "none", null - | - */ - - 'same_site' => 'lax', - /* - |-------------------------------------------------------------------------- - | Partitioned Cookies - |-------------------------------------------------------------------------- - | - | Setting this value to true will tie the cookie to the top-level site for - | a cross-site context. Partitioned cookies are accepted by the browser - | when flagged "secure" and the Same-Site attribute is set to "none". - | - */ - - 'partitioned' => false, -]; diff --git a/config/view.php b/config/view.php deleted file mode 100644 index 24dea7a..0000000 --- a/config/view.php +++ /dev/null @@ -1,34 +0,0 @@ - [ - resource_path('views'), - ], - - /* - |-------------------------------------------------------------------------- - | Compiled View Path - |-------------------------------------------------------------------------- - | - | This option determines where all the compiled Blade templates will be - | stored for your application. Typically, this is within the storage - | directory. However, as usual, you are free to change this value. - | - */ - - 'compiled' => env( - 'VIEW_COMPILED_PATH', - realpath(storage_path('framework/views')) - ), -]; From f210136bb58c0a3296267dc9193d995be6002368 Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:34 +0000 Subject: [PATCH 04/14] Set new `ENV` variables --- .env.ci | 4 ++-- .env.example | 18 ++++++++++++++++-- ...ku-postgres-database-across-environments.md | 6 +++--- phpunit.xml | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.env.ci b/.env.ci index f3b9552..24d373e 100644 --- a/.env.ci +++ b/.env.ci @@ -7,8 +7,8 @@ APP_ENV=local LOG_CHANNEL=stack LOG_LEVEL=debug -BROADCAST_DRIVER=log -CACHE_DRIVER=file +BROADCAST_CONNECTION=log +CACHE_STORE=file FILESYSTEM_DISK=local QUEUE_CONNECTION=sync SESSION_DRIVER=file diff --git a/.env.example b/.env.example index 34f5c5b..dffa204 100644 --- a/.env.example +++ b/.env.example @@ -1,12 +1,23 @@ APP_NAME=Laravel APP_KEY=base64:UhYJmk1UQ59RWxNDQAT+vLgTcOre1hQ1pK/sjEhfrsg= APP_DEBUG=true +APP_TIMEZONE=UTC APP_URL=http://localhost +APP_LOCALE=en +APP_FALLBACK_LOCALE=en +APP_FAKER_LOCALE=en_US + +APP_MAINTENANCE_DRIVER=file +APP_MAINTENANCE_STORE=database + +BCRYPT_ROUNDS=12 + APP_ENV=local ASSET_URL=http://localhost:3000 LOG_CHANNEL=stack +LOG_STACK=single LOG_LEVEL=debug DB_CONNECTION=mysql @@ -16,12 +27,15 @@ DB_DATABASE=laravel DB_USERNAME=root DB_PASSWORD= -BROADCAST_DRIVER=log -CACHE_DRIVER=file +BROADCAST_CONNECTION=log +CACHE_STORE=file FILESYSTEM_DISK=local QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120 +SESSION_ENCRYPT=false +SESSION_PATH=/ +SESSION_DOMAIN=null MEMCACHED_HOST=127.0.0.1 diff --git a/content/pages/how-to-copy-heroku-postgres-database-across-environments.md b/content/pages/how-to-copy-heroku-postgres-database-across-environments.md index 28b31a3..d23d33d 100644 --- a/content/pages/how-to-copy-heroku-postgres-database-across-environments.md +++ b/content/pages/how-to-copy-heroku-postgres-database-across-environments.md @@ -11,12 +11,12 @@ created_at: 2022-04-04 If you find yourself needing to copy a database across environments (say production to staging) you can use this one line command from Heroku: ``` -heroku pg:backups:restore {original_env}::{backup_id} {DATABASE_URL} --app {new_env} +heroku pg:backups:restore {original_env}::{backup_id} {DB_URL} --app {new_env} ``` Where: - `original_env` is the name of the environment you are pulling the backup from - `backup_id` is the ID of the backup, found on the Durability tab of the Heroku Postgres database page -- `DATABASE_URL` is the env var that Heroku generated for the new database -- `new_env` is the new application ID that has the `DATABASE_URL` attached to ti \ No newline at end of file +- `DB_URL` is the env var that Heroku generated for the new database +- `new_env` is the new application ID that has the `DB_URL` attached to ti \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml index df97509..3b3f5d3 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -20,7 +20,7 @@ - + From 66463315489b480d846e812f803d3ebd1eb07e58 Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:34 +0000 Subject: [PATCH 05/14] Default new `bootstrap/app.php` --- bootstrap/app.php | 72 +++++++++++------------------------------ bootstrap/providers.php | 5 +++ 2 files changed, 24 insertions(+), 53 deletions(-) create mode 100644 bootstrap/providers.php diff --git a/bootstrap/app.php b/bootstrap/app.php index 037e17d..d5d7e70 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,55 +1,21 @@ singleton( - Illuminate\Contracts\Http\Kernel::class, - App\Http\Kernel::class -); - -$app->singleton( - Illuminate\Contracts\Console\Kernel::class, - App\Console\Kernel::class -); - -$app->singleton( - Illuminate\Contracts\Debug\ExceptionHandler::class, - App\Exceptions\Handler::class -); - -/* -|-------------------------------------------------------------------------- -| Return The Application -|-------------------------------------------------------------------------- -| -| This script returns the application instance. The instance is given to -| the calling script so we can separate the building of the instances -| from the actual running of the application and sending responses. -| -*/ - -return $app; +use Illuminate\Foundation\Application; +use Illuminate\Foundation\Configuration\Exceptions; +use Illuminate\Foundation\Configuration\Middleware; + +return Application::configure(basePath: dirname(__DIR__)) + ->withProviders() + ->withRouting( + web: __DIR__.'/../routes/web.php', + // api: __DIR__.'/../routes/api.php', + commands: __DIR__.'/../routes/console.php', + // channels: __DIR__.'/../routes/channels.php', + health: '/up', + ) + ->withMiddleware(function (Middleware $middleware) { + // + }) + ->withExceptions(function (Exceptions $exceptions) { + // + })->create(); diff --git a/bootstrap/providers.php b/bootstrap/providers.php new file mode 100644 index 0000000..38b258d --- /dev/null +++ b/bootstrap/providers.php @@ -0,0 +1,5 @@ + Date: Mon, 25 Mar 2024 20:29:35 +0000 Subject: [PATCH 06/14] Re-register HTTP middleware --- app/Http/Kernel.php | 63 --------------------------------------------- bootstrap/app.php | 7 ++++- 2 files changed, 6 insertions(+), 64 deletions(-) delete mode 100644 app/Http/Kernel.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php deleted file mode 100644 index 0a4ee8b..0000000 --- a/app/Http/Kernel.php +++ /dev/null @@ -1,63 +0,0 @@ - [ - \Illuminate\Routing\Middleware\SubstituteBindings::class, - ], - - 'api' => [ - \Illuminate\Routing\Middleware\ThrottleRequests::class.':api', - \Illuminate\Routing\Middleware\SubstituteBindings::class, - ], - ]; - - /** - * The application's middleware aliases. - * - * Aliases may be used to conveniently assign middleware to routes and groups. - * - * @var array - */ - protected $middlewareAliases = [ - 'auth' => Middleware\Authenticate::class, - 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, - 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, - 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, - 'can' => \Illuminate\Auth\Middleware\Authorize::class, - 'guest' => Middleware\RedirectIfAuthenticated::class, - 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, - 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, - 'signed' => Middleware\ValidateSignature::class, - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, - 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, - ]; -} diff --git a/bootstrap/app.php b/bootstrap/app.php index d5d7e70..fdf7680 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -14,7 +14,12 @@ health: '/up', ) ->withMiddleware(function (Middleware $middleware) { - // + $middleware->redirectGuestsTo(fn () => route('login')); + $middleware->redirectUsersTo(RouteServiceProvider::HOME); + + $middleware->append(\Torchlight\Middleware\RenderTorchlight::class); + + $middleware->throttleApi(); }) ->withExceptions(function (Exceptions $exceptions) { // From c48f290360d14e7bd74ebf28315f59a396e4ce2d Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:35 +0000 Subject: [PATCH 07/14] Consolidate service providers --- .../Auth/AuthenticatedSessionController.php | 3 +- .../Auth/ConfirmablePasswordController.php | 3 +- ...mailVerificationNotificationController.php | 3 +- .../EmailVerificationPromptController.php | 3 +- .../Auth/RegisteredUserController.php | 3 +- .../Auth/VerifyEmailController.php | 5 +-- app/Providers/AppServiceProvider.php | 24 +++++++++++++ app/Providers/RouteServiceProvider.php | 36 ------------------- bootstrap/app.php | 3 +- 9 files changed, 39 insertions(+), 44 deletions(-) delete mode 100644 app/Providers/RouteServiceProvider.php diff --git a/app/Http/Controllers/Auth/AuthenticatedSessionController.php b/app/Http/Controllers/Auth/AuthenticatedSessionController.php index 2fddead..ef193df 100644 --- a/app/Http/Controllers/Auth/AuthenticatedSessionController.php +++ b/app/Http/Controllers/Auth/AuthenticatedSessionController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Http\Requests\Auth\LoginRequest; use App\Providers\RouteServiceProvider; @@ -34,7 +35,7 @@ public function store(LoginRequest $request): RedirectResponse $request->session()->regenerate(); - return redirect()->intended(RouteServiceProvider::HOME); + return redirect()->intended(AppServiceProvider::HOME); } /** diff --git a/app/Http/Controllers/Auth/ConfirmablePasswordController.php b/app/Http/Controllers/Auth/ConfirmablePasswordController.php index 07be52f..9d81e2d 100644 --- a/app/Http/Controllers/Auth/ConfirmablePasswordController.php +++ b/app/Http/Controllers/Auth/ConfirmablePasswordController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Providers\RouteServiceProvider; use Illuminate\Http\RedirectResponse; @@ -35,6 +36,6 @@ public function store(Request $request): RedirectResponse $request->session()->put('auth.password_confirmed_at', time()); - return redirect()->intended(RouteServiceProvider::HOME); + return redirect()->intended(AppServiceProvider::HOME); } } diff --git a/app/Http/Controllers/Auth/EmailVerificationNotificationController.php b/app/Http/Controllers/Auth/EmailVerificationNotificationController.php index cdac563..52ee027 100644 --- a/app/Http/Controllers/Auth/EmailVerificationNotificationController.php +++ b/app/Http/Controllers/Auth/EmailVerificationNotificationController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Providers\RouteServiceProvider; use Illuminate\Http\Request; @@ -16,7 +17,7 @@ class EmailVerificationNotificationController extends Controller public function store(Request $request) { if ($request->user()->hasVerifiedEmail()) { - return redirect()->intended(RouteServiceProvider::HOME); + return redirect()->intended(AppServiceProvider::HOME); } $request->user()->sendEmailVerificationNotification(); diff --git a/app/Http/Controllers/Auth/EmailVerificationPromptController.php b/app/Http/Controllers/Auth/EmailVerificationPromptController.php index fe0de42..df14317 100644 --- a/app/Http/Controllers/Auth/EmailVerificationPromptController.php +++ b/app/Http/Controllers/Auth/EmailVerificationPromptController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Providers\RouteServiceProvider; use Illuminate\Http\Request; @@ -15,7 +16,7 @@ class EmailVerificationPromptController extends Controller public function __invoke(Request $request) { return $request->user()->hasVerifiedEmail() - ? redirect()->intended(RouteServiceProvider::HOME) + ? redirect()->intended(AppServiceProvider::HOME) : Inertia::render('Auth/VerifyEmail', ['status' => session('status')]); } } diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index f9af928..4fb96d3 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Models\User; use App\Providers\RouteServiceProvider; @@ -47,6 +48,6 @@ public function store(Request $request): RedirectResponse Auth::login($user); - return redirect(RouteServiceProvider::HOME); + return redirect(AppServiceProvider::HOME); } } diff --git a/app/Http/Controllers/Auth/VerifyEmailController.php b/app/Http/Controllers/Auth/VerifyEmailController.php index ea87940..98b4a84 100644 --- a/app/Http/Controllers/Auth/VerifyEmailController.php +++ b/app/Http/Controllers/Auth/VerifyEmailController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Providers\RouteServiceProvider; use Illuminate\Auth\Events\Verified; @@ -16,13 +17,13 @@ class VerifyEmailController extends Controller public function __invoke(EmailVerificationRequest $request): RedirectResponse { if ($request->user()->hasVerifiedEmail()) { - return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); + return redirect()->intended(AppServiceProvider::HOME.'?verified=1'); } if ($request->user()->markEmailAsVerified()) { event(new Verified($request->user())); } - return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); + return redirect()->intended(AppServiceProvider::HOME.'?verified=1'); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 5dbfe08..1362898 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,10 +2,23 @@ namespace App\Providers; +use Illuminate\Cache\RateLimiting\Limit; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\RateLimiter; +use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { + /** + * The path to the "home" route for your application. + * + * This is used by Laravel authentication to redirect users after login. + * + * @var string + */ + public const HOME = '/dashboard'; + /** * Register any application services. */ @@ -31,5 +44,16 @@ public function boot(): void ->withUrl() ->twitterSite('owenconti') ->image('https://snaps-proxy.owenconti.workers.dev?w=1200&h=632&dpi=2&url=https://owenconti.com/og-image/?data='.base64_encode(json_encode(['title' => 'Owen Conti', 'date' => now()->format('M d, Y')]))); + + $this->bootRoute(); + } + + public function bootRoute(): void + { + RateLimiter::for('api', function (Request $request) { + return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); + }); + + } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php deleted file mode 100644 index 6039dc9..0000000 --- a/app/Providers/RouteServiceProvider.php +++ /dev/null @@ -1,36 +0,0 @@ -by($request->user()?->id ?: $request->ip()); - }); - - $this->routes(function () { - Route::middleware('web') - ->group(base_path('routes/web.php')); - }); - } -} diff --git a/bootstrap/app.php b/bootstrap/app.php index fdf7680..73dfc2e 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,5 +1,6 @@ withMiddleware(function (Middleware $middleware) { $middleware->redirectGuestsTo(fn () => route('login')); - $middleware->redirectUsersTo(RouteServiceProvider::HOME); + $middleware->redirectUsersTo(AppServiceProvider::HOME); $middleware->append(\Torchlight\Middleware\RenderTorchlight::class); From a2c9253c6f4cf4daa688aa190ee77e39d3593624 Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:35 +0000 Subject: [PATCH 08/14] Re-register service providers --- config/app.php | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 config/app.php diff --git a/config/app.php b/config/app.php deleted file mode 100644 index a14dd79..0000000 --- a/config/app.php +++ /dev/null @@ -1,23 +0,0 @@ - ServiceProvider::defaultProviders()->merge([ - /* - * Package Service Providers... - */ - - /* - * Application Service Providers... - */ - App\Providers\AppServiceProvider::class, - App\Providers\AuthServiceProvider::class, - // App\Providers\BroadcastServiceProvider::class, - App\Providers\EventServiceProvider::class, - App\Providers\RouteServiceProvider::class, - ])->toArray(), - -]; From 7a2ba62b059c8f4ad68eaf661deb99fa727fe817 Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:37 +0000 Subject: [PATCH 09/14] Re-register routes --- bootstrap/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index 73dfc2e..635065d 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -11,7 +11,7 @@ web: __DIR__.'/../routes/web.php', // api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', - // channels: __DIR__.'/../routes/channels.php', + channels: __DIR__.'/../routes/channels.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware) { From b4a239296392ca66d25a2e048d1a97d7dfd2b76d Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:37 +0000 Subject: [PATCH 10/14] Bump Composer dependencies --- composer.json | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index e38e8c2..205a665 100644 --- a/composer.json +++ b/composer.json @@ -9,31 +9,30 @@ "license": "MIT", "require": { "php": "^8.2", - "archtechx/laravel-pages": "^0.2", + "archtechx/laravel-pages": "^0.3", "guzzlehttp/guzzle": "^7.2", - "laravel/framework": "^10.48", - "laravel/tinker": "^2.8", + "laravel/framework": "^11.0", + "laravel/tinker": "^2.9", "laravel/vapor-cli": "^1.64", "laravel/vapor-core": "^2.37", "league/commonmark": "^2.4", "league/flysystem-aws-s3-v3": "^3.24", - "lorisleiva/laravel-actions": "^2.7", + "lorisleiva/laravel-actions": "^2.8", "spatie/laravel-feed": "^4.4", - "spatie/laravel-sitemap": "^6.2", - "spatie/once": "^3.1", + "spatie/laravel-sitemap": "^7.2", "tightenco/ziggy": "^2.0", "torchlight/torchlight-commonmark": "^0.5.5", "torchlight/torchlight-laravel": "^0.5.14" }, "require-dev": { - "fakerphp/faker": "^1.9.1", + "fakerphp/faker": "^1.23", "friendsofphp/php-cs-fixer": "^3.51", - "laravel/sail": "^1.25", - "mockery/mockery": "^1.4.4", - "nunomaduro/collision": "^7.0", - "phpunit/phpunit": "^10.1", + "laravel/sail": "^1.26", + "mockery/mockery": "^1.6", + "nunomaduro/collision": "^8.0", + "phpunit/phpunit": "^10.5", "squizlabs/php_codesniffer": "^3.9", - "spatie/laravel-ignition": "^2.0" + "spatie/laravel-ignition": "^2.4" }, "autoload": { "psr-4": { @@ -73,6 +72,6 @@ "preferred-install": "dist", "sort-packages": true }, - "minimum-stability": "stable", + "minimum-stability": "dev", "prefer-stable": true } From 9a01fe82891dbfbb3292ff574060f8b9dc166820 Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:38 +0000 Subject: [PATCH 11/14] Convert `$casts` property to method --- app/Models/User.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 3452903..47737f6 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -34,13 +34,16 @@ class User extends Authenticatable ]; /** - * The attributes that should be cast to native types. + * Get the attributes that should be cast. * - * @var array + * @return array */ - protected $casts = [ - 'email_verified_at' => 'datetime', - ]; + protected function casts(): array + { + return [ + 'email_verified_at' => 'datetime', + ]; + } public function teams(): BelongsToMany { From 6d79bc1f24c7d96f3d5723e3608fb4c1bbb49ce7 Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:38 +0000 Subject: [PATCH 12/14] Mark base controller as `abstract` --- app/Http/Controllers/Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index f1406be..c299cc5 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -6,7 +6,7 @@ use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; -class Controller extends BaseController +abstract class Controller extends BaseController { use AuthorizesRequests; use ValidatesRequests; From 52f0c703bf733f6c6afef37952bfbd2ac928ef41 Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:38 +0000 Subject: [PATCH 13/14] Remove `CreatesApplication` testing trait --- tests/CreatesApplication.php | 21 --------------------- tests/TestCase.php | 2 +- 2 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 tests/CreatesApplication.php diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php deleted file mode 100644 index cc68301..0000000 --- a/tests/CreatesApplication.php +++ /dev/null @@ -1,21 +0,0 @@ -make(Kernel::class)->bootstrap(); - - return $app; - } -} diff --git a/tests/TestCase.php b/tests/TestCase.php index 2932d4a..fe1ffc2 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,5 +6,5 @@ abstract class TestCase extends BaseTestCase { - use CreatesApplication; + // } From 49c2b079e35b2bfc9ffffea037d13864a077ec40 Mon Sep 17 00:00:00 2001 From: Shift Date: Mon, 25 Mar 2024 20:29:39 +0000 Subject: [PATCH 14/14] Shift cleanup --- app/Http/Controllers/Auth/AuthenticatedSessionController.php | 3 +-- app/Http/Controllers/Auth/ConfirmablePasswordController.php | 3 +-- .../Auth/EmailVerificationNotificationController.php | 3 +-- .../Controllers/Auth/EmailVerificationPromptController.php | 3 +-- app/Http/Controllers/Auth/RegisteredUserController.php | 3 +-- app/Http/Controllers/Auth/VerifyEmailController.php | 3 +-- app/Providers/AppServiceProvider.php | 2 -- config/auth.php | 2 -- config/database.php | 2 -- config/mail.php | 2 -- config/services.php | 2 -- tests/TestCase.php | 1 - 12 files changed, 6 insertions(+), 23 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthenticatedSessionController.php b/app/Http/Controllers/Auth/AuthenticatedSessionController.php index ef193df..f7612b1 100644 --- a/app/Http/Controllers/Auth/AuthenticatedSessionController.php +++ b/app/Http/Controllers/Auth/AuthenticatedSessionController.php @@ -2,10 +2,9 @@ namespace App\Http\Controllers\Auth; -use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Http\Requests\Auth\LoginRequest; -use App\Providers\RouteServiceProvider; +use App\Providers\AppServiceProvider; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; diff --git a/app/Http/Controllers/Auth/ConfirmablePasswordController.php b/app/Http/Controllers/Auth/ConfirmablePasswordController.php index 9d81e2d..c26b7a6 100644 --- a/app/Http/Controllers/Auth/ConfirmablePasswordController.php +++ b/app/Http/Controllers/Auth/ConfirmablePasswordController.php @@ -2,9 +2,8 @@ namespace App\Http\Controllers\Auth; -use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; +use App\Providers\AppServiceProvider; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; diff --git a/app/Http/Controllers/Auth/EmailVerificationNotificationController.php b/app/Http/Controllers/Auth/EmailVerificationNotificationController.php index 52ee027..d3fc1d6 100644 --- a/app/Http/Controllers/Auth/EmailVerificationNotificationController.php +++ b/app/Http/Controllers/Auth/EmailVerificationNotificationController.php @@ -2,9 +2,8 @@ namespace App\Http\Controllers\Auth; -use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; +use App\Providers\AppServiceProvider; use Illuminate\Http\Request; class EmailVerificationNotificationController extends Controller diff --git a/app/Http/Controllers/Auth/EmailVerificationPromptController.php b/app/Http/Controllers/Auth/EmailVerificationPromptController.php index df14317..0cf1678 100644 --- a/app/Http/Controllers/Auth/EmailVerificationPromptController.php +++ b/app/Http/Controllers/Auth/EmailVerificationPromptController.php @@ -2,9 +2,8 @@ namespace App\Http\Controllers\Auth; -use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; +use App\Providers\AppServiceProvider; use Illuminate\Http\Request; use Inertia\Inertia; diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index 4fb96d3..cbc72bb 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -2,10 +2,9 @@ namespace App\Http\Controllers\Auth; -use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Models\User; -use App\Providers\RouteServiceProvider; +use App\Providers\AppServiceProvider; use Illuminate\Auth\Events\Registered; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; diff --git a/app/Http/Controllers/Auth/VerifyEmailController.php b/app/Http/Controllers/Auth/VerifyEmailController.php index 98b4a84..c93b024 100644 --- a/app/Http/Controllers/Auth/VerifyEmailController.php +++ b/app/Http/Controllers/Auth/VerifyEmailController.php @@ -2,9 +2,8 @@ namespace App\Http\Controllers\Auth; -use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; +use App\Providers\AppServiceProvider; use Illuminate\Auth\Events\Verified; use Illuminate\Foundation\Auth\EmailVerificationRequest; use Illuminate\Http\RedirectResponse; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1362898..cfcc1ba 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -53,7 +53,5 @@ public function bootRoute(): void RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); }); - - } } diff --git a/config/auth.php b/config/auth.php index 1642fb2..fe4d782 100644 --- a/config/auth.php +++ b/config/auth.php @@ -1,7 +1,6 @@ [ 'api' => [ 'driver' => 'token', @@ -9,5 +8,4 @@ 'hash' => false, ], ], - ]; diff --git a/config/database.php b/config/database.php index 1fc8066..a53eb4e 100644 --- a/config/database.php +++ b/config/database.php @@ -1,10 +1,8 @@ [ 'table' => 'migrations', 'update_date_on_publish' => false, // disable to preserve original behavior for existing applications ], - ]; diff --git a/config/mail.php b/config/mail.php index f88455f..ee85a54 100644 --- a/config/mail.php +++ b/config/mail.php @@ -1,7 +1,6 @@ [ 'mailgun' => [ 'transport' => 'mailgun', @@ -18,5 +17,4 @@ ], ], ], - ]; diff --git a/config/services.php b/config/services.php index 62e0a08..e410bc3 100644 --- a/config/services.php +++ b/config/services.php @@ -1,12 +1,10 @@ [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 'scheme' => 'https', ], - ]; diff --git a/tests/TestCase.php b/tests/TestCase.php index fe1ffc2..539c7dd 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,5 +6,4 @@ abstract class TestCase extends BaseTestCase { - // }