Search code examples
phplaravelgitcomposer-phplaravel-10

Upgrading Laravel from 9 to 10. Update files outside of vendor folder


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 App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $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 App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel 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');
    }
}

Solution

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