winter icon indicating copy to clipboard operation
winter copied to clipboard

Add support for Laravel 9 LTS

Open LukeTowers opened this issue 3 years ago • 3 comments

Refs: octobercms/october#5473. Credit to @filipac for the initial work!

I've successfully upgraded a fresh OctoberCMS to use Laravel ^8.0 ( 8.25.0 as of speaking) from Laravel 6 we currently use. I am sure there is no desire from core team to upgrade to non-lts version for now, but I just want to document what changes should we make to have it working:

  • require laravel components ^8.0
  • upgrade symfony/yaml in october/rain to ^5.1
  • classes in October\Rain\Database\Query\Grammars give an exception because the implementation is not as in parent class. Changed the compileUpsert functions to use Illuminate\Database\Query\Builder instead of October\Rain\Database\QueryBuilder and it worked.
  • October\Rain\Events\Dispatcher needed an update especially in listen method cause the signature changed
  • in Foundation/Bootstrap/LoadEnvironmentVariables we need to change the way Dotenv::create is called (first parameter now should be \Illuminate\Support\Env::getRepository(), the other 2 parameters remain the same.
  • in Exception/Handler we should change \Exception to \Throwable. backend/models/brandsetting/fields.yaml needs an update in availableColors keys because the new
  • Symfony Yaml parser sees colors as a comment and we get an exception of invalid Yaml. Did not check other yaml files if they include # but we should do that.
  • Laravel 9 will require at least PHP 7.4

Otherwise, everything seems to work so far on Laravel 8.0. Not sure what the changes will be in 9.0 which is scheduled for September this year, this will be the next LTS. But from what I've seen on Github, nothing too breaking, just upgrading some components.

I think we should be prepared to upgrade anytime and maybe sometime in the future try to mirror the latest supported version of Laravel (not only LTS) since we will now have only one per year. If we keep piling up versions to upgrade, it becomes a nightmare job. Since October is evergreen and we now have some kind of versioning, I do not see a problem mirroring latest Laravel, especially since we have a wrapper around the framework and not much of our/plugin's code needs to be updated.

Is this repo the best place to have this checklist registered, or is https://github.com/octoberrain/meta more suited?

Just want to help and stay on track with the great Laravel releases, this would be a strong point for us (see Statamic which always supports latest versions of Laravel).

We've been discussing in #5271 about running a pre-processor for Yaml files to gain compatibility with the later versions of symfony/yaml, as all our docs and I would say the vast majority of plugin Yaml files will be using a syntax that is no longer compatible, especially when it comes to the version number keys. This would have to be implemented before we can consider upgrading the Yaml library.

Otherwise, everything looks relatively graceful.

Did you happen to run the unit tests and confirm that everything still passed?

@bennothommo i've run them now. Here's what I found so far

  • some tests fail due to invalid yaml in fixtures
  • we have to register in the container a new service "mail.manager" - \Illuminate\Mail\MailManager should be extended to suit October's needs
  • the mail system is a bit changed, the config file from legacy version still works but the Mail facade now points to the MailManager class.
  • Declaration of October\Rain\Database\Pivot::setKeysForSaveQuery(Illuminate\Database\Eloquent\Builder $query) should be compatible with Illuminate\Database\Eloquent\Model::setKeysForSaveQuery($query)
    1. CmsExceptionTest::testCmsExceptionPhp Error: Class 'Symfony\Component\Debug\Exception\FatalErrorException' not found - the new alternative is \Symfony\Component\ErrorHandler\Error\FatalError
  • \October\Rain\Exception\ExceptionBase methods setMask and applyMask should receive \Throwable
  • same in \Cms\Classes\CmsException - replace exception with \Throwable
  • AttachOneModelTest fails because the signature of UploadedFile changed and file_size is no longer required
  • UploadedFile method getClientSize no longer exists, change to getSize in \October\Rain\Database\Attach\File
  • MassAsignment no longer works because in laravel it was moved to Concerns\GuardsAttributes and we do not apply it on our model;

LukeTowers avatar Mar 12 '21 06:03 LukeTowers

I'd like to help with this. Should it be pushed to the main develop branch or will there be a separate branch for this specific upgrade?

tschallacka avatar Apr 25 '21 16:04 tschallacka

https://github.com/wintercms/winter/tree/wip/1.2 https://github.com/wintercms/storm/tree/wip/1.2

LukeTowers avatar Apr 25 '21 16:04 LukeTowers

This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days. If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue. If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

github-actions[bot] avatar Jun 26 '21 00:06 github-actions[bot]

Laravel 9 support is now implemented in Winter CMS 1.2

bennothommo avatar Aug 25 '22 12:08 bennothommo