deanlaw's avatar

Laravel Upgrading Process Question

I have an site that I originally created using v10 and have since upgraded it to v11 and then v12. I just did a diff of my site and a brand new empty v12 install and noticed that all my app config and most of my Laravel vendor framework files are slightly different from the fresh installed app. My assumption was that the upgrade replaced these core files, but it doesn't appear so. I have double checked and both my existing site and the fresh install are reporting that they are running the same 12.21.0 version. My question is, should I be manually merging these differences back into my site?

0 likes
4 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Great question! This is a common point of confusion when upgrading Laravel applications.

Short Answer:
Yes, you should review and consider merging relevant changes from the new Laravel version’s config and stub files into your existing application, but you should do so carefully and manually.

Explanation:

  • Laravel Upgrade Process:
    When you upgrade Laravel (e.g., from v10 → v11 → v12), Composer only updates the files in the vendor/ directory. Your application files (like those in config/, app/, etc.) are not automatically updated or overwritten. This is by design, so your customizations are not lost.

  • Why Are There Differences?
    Each new Laravel release may introduce changes to the default config files, stubs, or even structure. These are only present in new installations, not in upgraded projects.

  • What Should You Do?

    • Review the Laravel Upgrade Guide:
      Each major release comes with an upgrade guide that lists required changes. Always follow this guide first.
    • Compare Files:
      Use a tool like Laravel Shift's Workbench or a diff tool to compare your files with those from a fresh install.
    • Merge Carefully:
      • For files like config/app.php, config/auth.php, etc., manually merge in new options or settings as needed.
      • For files you have customized, be careful not to overwrite your changes.
      • Some files may have new keys or improved defaults. Add these as appropriate.
    • Vendor Files:
      The vendor/laravel/framework files are updated by Composer. If you see differences here, ensure your Composer dependencies are up to date:
      composer update
      
      You should not manually edit files in vendor/.

Summary Table:

File Type Automatically Updated? Action Required?
vendor/ Yes (via Composer) No manual changes needed
config/, app/ No Manually review/merge

Helpful Command:
To see what files have changed in your app after a fresh install, you can use:

git diff <your-branch> <fresh-install-branch>

Conclusion:
Always review and merge changes from new Laravel releases into your app’s config and stub files. This keeps your app up-to-date with new features, security patches, and best practices.

If you want an automated approach, consider using Laravel Shift to handle upgrades and file merging for you.

Glukinho's avatar

If upgrade process finished without errors and everything works fine - then no, you shouldn't merge anything by hand (especially vendor folder which is never to be touched).

Laravel changes it's settings and structure from version to version and therefore it also supports settings and structure from previous versions (aka backward compatibility) - otherwise you have to rewrite a lot just to upgrade to new version of framework.

For example, Laravel 8 had app/Console/Kernel.php file which used to hold task scheduling settings. Laravel 12 changed task sheduling to routes/console.php, but old Kernel.php is still supported in v12 to let old projects upgrade without problems.

Snapey's avatar

The upgrade process does not require you to change anything that is not already listed in the upgrade guide.

deanlaw's avatar

Thank you, Glukinho & Snapey for the additional clarification on the upgrade process.

Please or to participate in this conversation.