search

Home  >  Q&A  >  body text

Upgrading Laravel 9 to 10: Update files outside vendor folder

I want to upgrade an existing Laravel 9 project to version 10. The goal is that not only vendor files can be updated via Composer. Additionally, I would like changes in my project code to be reflected outside of the vendor folder.

I upgraded my project following the Laravel documentation's upgrade guide.

This is the changed file.

For example my app/Console/Kernel.php should be changed 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.
     *
     * @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');
    }
}

P粉546138344P粉546138344244 days ago402

reply all(2)I'll reply

  • P粉792026467

    P粉7920264672024-03-28 09:09:17

    Automatically updating such "sample" files may not be possible at all automatically, since users can edit them in their projects, which is why they are not in the vendor.

    The best option for updating PHP related syntax (such as the type hints mentioned) would probably be something like PHP-CS-Fixer with the appropriate rules, but your function example cannot use it because that requires the old definition via PHPDoc return type.

    If you modified these files, you can manually copy the changes from the Laravel repository and adapt them to your code.

    reply
    0
  • P粉002546490

    P粉0025464902024-03-28 00:41:58

    Changes to Laravel's new application framework can be viewed on Github via its comparison tool: https://github.com/laravel/laravel/compare/9.x...10.x

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

    These changes can be converted into a .patch file, which you can then apply to your application. Github once again provides a fairly simple way to do this; https://github.com/laravel/laravel/compare/9.x...10.x.patch.

    After you save the .patch file locally, you can use git apply <path-to-patch-file> to apply it to your repository. In most cases this should work perfectly.

    To be clear, this is not a replacement for following https://laravel.com/docs/10.x/upgrade as it will only do the necessary changes to the default application framework Tweak; it does not update the code you write in Laravel in any way.

    reply
    0
  • Cancelreply