Laravel 12.x Upgrade and Package Updates
Laravel 12.x Upgrade and Package Updates
This PR includes several important updates and improvements to bring Wave up to date with Laravel 12.x and its dependencies.
Key Changes
Laravel 12 Compatibility Updates
- Updated environment variables to match Laravel 12 naming conventions
- Renamed
MAIL_ENCRYPTIONtoMAIL_SCHEME - Added
DB_COLLATIONwithutf8mb4_unicode_cidefault - Removed deprecated
APP_TIMEZONE(now defaults to UTC)
- Renamed
- Updated storage configuration to use new
storage/app/privatefolder structure - Updated array return types in notification classes for Laravel 12 compatibility
Package Updates
- Updated
intervention/imagefrom 2.7.2 to 3.11.3 - Updated
stripe/stripe-phpfrom 15.10.0 to 17.3.0 - Updated various Filament and Livewire assets
Testing
- All composer dependencies have been updated and verified
- Configuration, route, and view caches have been cleared
- Filament assets have been republished
- Livewire assets have been republished
Breaking Changes
- Applications using custom timezone settings should now configure them in
config/app.php - Local storage disk now uses
storage/app/privateas its root - Applications using the old
MAIL_ENCRYPTIONenv var need to update toMAIL_SCHEME
Next Steps
After merging this PR, you should:
- Update your
.envfile with any renamed variables - Clear all caches (
config,route,view) - Run any database migrations
- Test all file upload functionality due to storage path changes
Excellent 👏 Thanks for the PR.
Can you tell me what the big changes were to upgrade to 12.x? It looks like you ran a linter, which is great, but the PR is so big it's hard to pin point the upgrade areas.
Also, can you run through the installer and make sure everything is working correctly in this PR. The tests are failing because it's trying to run through the installer process and something might be broken in that area.
Thanks again 🤠
Looking forward to getting this merged soon 😊
The Issue The problem was occurring during the GitHub Actions workflow for your PR #242 because Laravel 12 changed how it handles database paths. In Laravel 12, the database directory structure might not be created automatically, which was causing your installation process to fail when it tried to create the SQLite database file.
The Solution I've updated the installation code in install.blade.php to:
- First check if the database directory exists
- Create the directory structure if it doesn't exist (with appropriate permissions)
- Then create the SQLite database file
This ensures that even in Laravel 12's environment, the database directory will be properly set up before attempting to create the database file.
Hey Tony, thanks for checking out my PR! Basically I have just ranthrough Laravel Shift, and checked everything as per the shift instructions locally, my project is Running completely fine locally.
About the main changes for upgrading to Laravel 12.x - you're right that there's quite a lot going on in the PR. Most of the bulk comes from Laravel Shift running through the codebase, but I can highlight the key upgrades:
Major Changes in the Laravel 12.x Upgrade
-
PHP 8.2+ Compatibility: The codebase is now fully compatible with PHP 8.2-8.4 (the versions supported by Laravel 12). This required updating method signatures, typehints, and handling deprecations.
-
Modern Routing Patterns: The PR updates all routes to use Laravel's modern fluent syntax instead of the older options arrays. For example, changing things like
Route::get('home', ['uses' => 'HomeController@index'])to the cleanerRoute::get('home', [HomeController::class, 'index']). -
New Application Structure: Laravel 12 introduces several structural changes, particularly in:
- The bootstrap/app.php file (completely restructured)
- Service provider registration (more streamlined approach)
- HTTP middleware registration
- Config file organization
-
Type Safety Improvements: I replaced string-based class references with
::classnotation throughout the codebase, which improves type safety and IDE support. -
Dependency Updates: Updated several critical dependencies including:
- intervention/image to 2.7+
- laravel/framework to 12.x
- All dev dependencies to compatible versions
-
Controller Modernization: Removed unused traits (ValidatesRequests, DispatchesJobs, AuthorizesRequests) and updated controller patterns to match Laravel 12's approach.
-
Model Updates: Converted $casts properties to methods where appropriate to match Laravel's recommended patterns.
The Installer Fix
I've identified and fixed the installer issue that was causing the GitHub Actions tests to fail. The problem was that Laravel 12 changed how it handles database paths, and the installer wasn't properly creating directory structures before trying to create database files.
Here's what I changed:
// Make sure the database directory exists first (this was missing)
$databaseDir = dirname(database_path('database.sqlite'));
if (!\Illuminate\Support\Facades\File::exists($databaseDir)) {
\Illuminate\Support\Facades\File::makeDirectory($databaseDir, 0755, true);
}
// Then create the database file as before
if (!\Illuminate\Support\Facades\File::exists(database_path('database.sqlite'))) {
\Illuminate\Support\Facades\File::put(database_path('database.sqlite'), '');
}
I've tested the installation process from scratch locally and it works correctly with this change. The installer should now properly create the database structure before attempting to use it.
If there are any specific parts of the PR you'd like me to explain further, just let me know! Happy to walk through any section in more detail.
That's amazing @cogneiss-admin 👏 I love it. Thanks again.
Ok, I have one final request before we can merge this in. I seen that you added intervention/image package as a dep.
This had been added previously, but it was removed. The reason it was removed was because it required the GD php extension and unfortunately that was not installed by default with Herd.
I want to make sure that the application works out of the box with a fresh installation of Herd. This may well have changed. They may have included the GD lib by default, but it would be nice to double check.
Not sure why the CI tests still failed, but if you could look at that and the GD lib stuff above, then I can look at getting this merged in.
Looking forward to getting this merged in. I'll be trying to upgrade to Filament V4 very soon.
@tnylea
I removed intervention image package.
for workflow I am thinking the following changes might fix it but for that I think you can be better judge.
- name: Create .env file
run: |
cd project_folder
cp .env.example .env
sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/g' .env
sed -i 's/DB_DATABASE=wave/DB_DATABASE=database\/database.sqlite/g' .env
touch database/database.sqlite
- name: Install Composer dependencies
run: |
cd project_folder
composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Set up Laravel application
run: |
cd project_folder
php artisan key:generate
mkdir -p database
chmod -R 777 storage bootstrap/cache database
Can't wait to see Filament 4 integrated Happy to help on that part too if needed.
Hi @tnylea anything else I can help with this? Really want this to get merged :)
Thanks @cogneiss-admin, looks great. There's still a few updates I need to put back in the public/index.php. I'm going to merge this into a new branch https://github.com/thedevdojo/wave/tree/l12upgrade and then I'll make those updates and this should be merged in to main with the next hour 😉
Thanks again. Here's the new PR into main (https://github.com/thedevdojo/wave/pull/246) 👏