wave icon indicating copy to clipboard operation
wave copied to clipboard

Laravel 12.x Upgrade and Package Updates

Open cogneiss-admin opened this issue 7 months ago • 4 comments

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_ENCRYPTION to MAIL_SCHEME
    • Added DB_COLLATION with utf8mb4_unicode_ci default
    • Removed deprecated APP_TIMEZONE (now defaults to UTC)
  • Updated storage configuration to use new storage/app/private folder structure
  • Updated array return types in notification classes for Laravel 12 compatibility

Package Updates

  • Updated intervention/image from 2.7.2 to 3.11.3
  • Updated stripe/stripe-php from 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/private as its root
  • Applications using the old MAIL_ENCRYPTION env var need to update to MAIL_SCHEME

Next Steps

After merging this PR, you should:

  1. Update your .env file with any renamed variables
  2. Clear all caches (config, route, view)
  3. Run any database migrations
  4. Test all file upload functionality due to storage path changes

cogneiss-admin avatar Jun 14 '25 06:06 cogneiss-admin

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 😊

tnylea avatar Jun 15 '25 02:06 tnylea

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:

  1. First check if the database directory exists
  2. Create the directory structure if it doesn't exist (with appropriate permissions)
  3. 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.

cogneiss-admin avatar Jun 15 '25 06:06 cogneiss-admin

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

  1. 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.

  2. 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 cleaner Route::get('home', [HomeController::class, 'index']).

  3. 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
  4. Type Safety Improvements: I replaced string-based class references with ::class notation throughout the codebase, which improves type safety and IDE support.

  5. Dependency Updates: Updated several critical dependencies including:

    • intervention/image to 2.7+
    • laravel/framework to 12.x
    • All dev dependencies to compatible versions
  6. Controller Modernization: Removed unused traits (ValidatesRequests, DispatchesJobs, AuthorizesRequests) and updated controller patterns to match Laravel 12's approach.

  7. 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.

cogneiss-admin avatar Jun 15 '25 07:06 cogneiss-admin

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 avatar Jun 16 '25 15:06 tnylea

@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.

cogneiss-admin avatar Jun 17 '25 07:06 cogneiss-admin

Hi @tnylea anything else I can help with this? Really want this to get merged :)

coding-sunshine avatar Jun 19 '25 15:06 coding-sunshine

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 😉

tnylea avatar Jun 21 '25 21:06 tnylea

Thanks again. Here's the new PR into main (https://github.com/thedevdojo/wave/pull/246) 👏

tnylea avatar Jun 21 '25 22:06 tnylea