Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel Slimmer #1700

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Laravel Slimmer #1700

wants to merge 19 commits into from

Conversation

omnicolor
Copy link
Owner

This pull request contains changes for slimming your Laravel application by removing core files which are no longer included in a new Laravel application.

Before merging, you need to:

  • Checkout the shift-130873 branch
  • Review all comments for additional changes
  • Thoroughly test your application (no tests?, no CI?)

If you need help modernizing your Laravel application, check out the Human Shifts.

@omnicolor
Copy link
Owner Author

ℹ️ To slim down the Laravel installation, Laravel 11 no longer has most of the core files previously included in the default Laravel application. While you are welcome to publish and customize these files, they are no longer required.

Shift takes an iterative approach to removing core files which are not customized or where its customizations may be done elsewhere in a modern Laravel 11 application. As such, you may see some commits removing files and others re-registering your customizations.

@omnicolor
Copy link
Owner Author

⚠️ The application bootstrapping changed in Laravel 11. As a result, files like artisan and public/index.php were rewritten. Shift overwrote these files but detected yours may have contained customizations. You should review the diff to see if any of your customizations are still needed.

@omnicolor
Copy link
Owner Author

ℹ️ Laravel 11 no longer requires you to maintain the default configuration files. Your configuration now merges with framework defaults.

Shift streamlined your configuration files by removing options that matched the Laravel defaults and preserving your true customizations. These are values which are not changeable through ENV variables.

If you wish to keep the full set of configuration files, Shift recommends running artisan config:publish --all --force to get the latest configuration files from Laravel 11, then reapplying the customizations Shift streamlined.

@omnicolor
Copy link
Owner Author

ℹ️ Shift detected customized options within your configuration files which may be set with an ENV variable. To help keep your configuration files streamlined, you may set the following variables. Be sure adjust any values per environment.

BCRYPT_ROUNDS=10
CACHE_STORE=file
DB_CONNECTION=mysql
MAIL_MAILER=smtp
QUEUE_CONNECTION=sync
SESSION_DRIVER=file

Note: some of these may simply be values which changed between Laravel versions. You may ignore any ENV variables you do not need to customize.

@omnicolor
Copy link
Owner Author

ℹ️ Shift detected your application uses custom ENV variables for configuration options which have ENV variables in Laravel. Shift recommends renaming the following variables to use the one provided by Laravel:

  • FILESYSTEM_DRIVER to FILESYSTEM_DISK

@omnicolor
Copy link
Owner Author

⚠️ The BROADCAST_DRIVER, CACHE_DRIVER, and DATABASE_URL environment variables were renamed in Laravel 11 to BROADCAST_CONNECTION, CACHE_STORE, and DB_URL, respectively.

Shift automated this change for your committed files, but you should review any additional locations where your environment is configured and update to the new variable names.

@omnicolor
Copy link
Owner Author

⚠️ Laravel 11 automatically discovers policies scanning your application's Policies directory at or above the directory containing your models.

Shift detected policies registered with the policies property of your AuthServiceProvider. If any of these policies can not be automatically discovered, you may register them manually using Gate::policy() in your AppServiceProvider.

@omnicolor
Copy link
Owner Author

⚠️ Shift was unable to re-register your exception handler. You may review the documentation to do so manually, or register your original exception handler by adding the following binding to the register method of your AppServiceProvider:

$this->app->bind(\Illuminate\Contracts\Debug\ExceptionHandler::class, \App\Exceptions\Handler::class);

@omnicolor
Copy link
Owner Author

❌ The app/Console/Kernel.php file has been removed in Laravel 11. Shift overwrote your file, but detected it may have contained customizations. You should review the diff to see if any of your customizations are still needed. If so, you may re-apply them to the routes/console.php file or the new bootstrap/app.php file. Review the documentation for additional details.

@omnicolor
Copy link
Owner Author

ℹ️ Laravel 11 now updates the timestamp when publishing vendor migrations. This may cause problems in existing applications when these migrations were previously published and ran with their default timestamp.

To preserve the original behavior, Shift disabled this feature in your database.php configuration file. If you do not have any vendor migrations or have squashed all of your existing migrations, you may re-enable the update_date_on_publish option. If this is the only customization within database.php, you may remove this configuration file.

@omnicolor
Copy link
Owner Author

ℹ️ The following files previously included in a Laravel application appeared to be customized and were not removed. Shift encourages you to review your customizations to see if they are still needed or may be done elsewhere in a modern Laravel application. Removing these files will keep your application modern and make future maintenance easier.

  • app/Http/Middleware/Authenticate.php
  • app/Http/Middleware/PreventRequestsDuringMaintenance.php
  • app/Providers/EventServiceProvider.php

@omnicolor
Copy link
Owner Author

⚠️ Many of the default drivers changed in Laravel 11. For example, the default database driver is sqlite and the default cache store is database. If you experience errors setting up your environment, be sure you have properly set your ENV variables for these drivers. If you wish to adopt the new defaults, you may follow the documentation to set them up for your application.

@omnicolor omnicolor self-assigned this Oct 11, 2024
@omnicolor omnicolor added php Pull requests that update PHP code chore Less fun tasks that need to be done labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Less fun tasks that need to be done php Pull requests that update PHP code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants