skip to Main Content

I want to upgrade my already existing Laravel 9 project to Version 10. The goal is, that not only the vendor files update through composer. Additionally I want to reflect the changes in my project’s code outside the vendor folder as well.

I followed the Upgrade Guide of the Laravel Documentation to upgrade my project.

Here are the files, that have been changed.

E.g. my app/Console/Kernel.php should change from

<?php

namespace AppConsole;

use IlluminateConsoleSchedulingSchedule;
use IlluminateFoundationConsoleKernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * Define the application's command schedule.
     *
     * @param  IlluminateConsoleSchedulingSchedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')->hourly();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

to

<?php

namespace AppConsole;

use IlluminateConsoleSchedulingSchedule;
use IlluminateFoundationConsoleKernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * Define the application's command schedule.
     */
    protected function schedule(Schedule $schedule): void
    {
        // $schedule->command('inspire')->hourly();
    }

    /**
     * Register the commands for the application.
     */
    protected function commands(): void
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

2

Answers


  1. Updating these kind of "example" files automatically may not be possible automatically at all since they are editable by users in their projects, that’s why they’re not in vendor.

    Your best bet for updating PHP-related syntax, such as mentioned type hints, may be something like PHP-CS-Fixer with appriopriate rules, but your example of functions wouldn’t work with that as that requires old way of defining return types through PHPDoc.

    Copying these changes manually from Laravel repository and adjusting them to your code, if you modified those files, is the way to go.

    Login or Signup to reply.
  2. The changes to the Laravel new app skeleton can be viewed on Github via their compare tool: https://github.com/laravel/laravel/compare/9.x…10.x

    (You can do this locally, using a GUI Git client or the Git command line, as well.)

    These changes can be turned into a .patch file, which you can then use to apply to your app. Github again provides a fairly easy way to do this; https://github.com/laravel/laravel/compare/9.x…10.x.patch.

    Once you have a .patch file saved locally, you can apply it within your repo using git apply <path-to-patch-file>. In most cases, this should apply cleanly.

    This is, to be clear, not a replacement for following the full upgrade guide at https://laravel.com/docs/10.x/upgrade, as it will only make the tweaks necessary for the default app skeleton; it will not update your own code you wrote in Laravel in any way.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search