Skip to content

Conversation

@rafaelstz
Copy link

@rafaelstz rafaelstz commented May 14, 2023

WHY are these changes introduced?

This PR upgrades Laravel 8 to 10.

WHAT is this pull request doing?

  • Upgrading Composer packages and dependencies.
  • Removing two third-party packages that became native.
  • Adjusting the link in the README file.
  • Removing PHP 8.0 support from CI.

Checklist

Note: once this PR is merged, it becomes a new release for this template.

  • I have added/updated tests for this change
  • I have made changes to the README.md file and other related documentation, if applicable

@rafaelstz rafaelstz changed the title Upgrade Laravel 8 to 10 [Feature] Upgrade Laravel 8 to 10 May 14, 2023
@grahamsutton
Copy link

grahamsutton commented May 31, 2023

@paulomarg Could we please get this reviewed and merged at your earliest convenience?

Laravel 8 is no longer receiving bug and security fixes as of January 24th, 2023. Laravel 10 will assure everyone is using the latest and most secure version of Laravel available. This should be a high priority item.

https://laravel.com/docs/8.x/releases#support-policy

@simone-boa-ideas
Copy link

simone-boa-ideas commented Jul 17, 2023

@paulomarg @mkevinosullivan Adding my voice to the chorus here :)
Having this would be really great!
The lack of a more updated version of Laravel is actually what's pushing us to use different unofficial solutions like laravel-shopify.
Of course, using the official and maintained version from Shopify would be much better, but we can't compromise on the app security (especially since Laravel 8 is not receiving security fixes anymore)

@angryalf
Copy link

when this be merged?

@zanderwar
Copy link

zanderwar commented Oct 5, 2025

tsk tsk, in 2 years not one shopify engineer had time for this, it literally took me longer to write these instructions then to upgrade...

Upgrade Laravel 8 -> Laravel 12

This only upgrades this template to Laravel 12, anything specific to your own app ensure you upgrade where appropriate (Laravel has migration instructions for each version)

Very straight forward, each version upgrade requires you to modify require and require-dev in your composer.json then run composer update afterwards (make sure you're in the /web/ dir of your app.

Test your app in between upgrades

8-9:

  1. Update composer.json, then run composer update in the web directory
"require": {
    "php": "^8.1",
    "ext-xml": "*",
    "ext-zip": "*",
    "doctrine/dbal": "^3.5",
    "fruitcake/laravel-cors": "^2.2",
    "guzzlehttp/guzzle": "^7.5",
    "laravel/framework": "^9.0",
    "laravel/tinker": "^2.8",
    "shopify/shopify-api": "^5.0",
    "squizlabs/php_codesniffer": "^3.9"
  },
  "require-dev": {
    "fakerphp/faker": "^1.21",
    "laravel/sail": "^1.18",
    "mockery/mockery": "^1.5",
    "nunomaduro/collision": "^6.0",
    "phpunit/phpunit": "^9.5",
    "spatie/laravel-ignition": "^1.0"
  }
  1. Replace app\Http\Middleware\TrustProxies.php with the below (it was absorbed by laravel at this point)
<?php

namespace App\Http\Middleware;

use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
{
    /**
     * The trusted proxies for this application.
     * Use `'*'` if behind a load balancer that sets proper X-Forwarded-* headers.
     *
     * @var array|string|null
     */
    protected $proxies = null;

    /**
     * The headers that should be used to detect proxies.
     *
     * @var int
     */
    protected $headers =
        Request::HEADER_X_FORWARDED_FOR |
        Request::HEADER_X_FORWARDED_HOST |
        Request::HEADER_X_FORWARDED_PORT |
        Request::HEADER_X_FORWARDED_PROTO |
        Request::HEADER_X_FORWARDED_AWS_ELB;
}

9-10

Super simple one

  1. Update composer.json, then run composer update in the web directory
{
  "require": {
    "php": "^8.1",
    "ext-xml": "*",
    "ext-zip": "*",
    "doctrine/dbal": "^3.6",
    "guzzlehttp/guzzle": "^7.8",
    "laravel/framework": "^10.0",
    "laravel/tinker": "^2.8",
    "shopify/shopify-api": "^5.0"
  },
  "require-dev": {
    "fakerphp/faker": "^1.23",
    "laravel/sail": "^1.29",
    "mockery/mockery": "^1.6",
    "nunomaduro/collision": "^7.0",
    "phpunit/phpunit": "^10.1",
    "spatie/laravel-ignition": "^2.0"
  }
}

10-11

{
  "require": {
    "php": "^8.2",
    "ext-xml": "*",
    "ext-zip": "*",
    "doctrine/dbal": "^3.7",
    "guzzlehttp/guzzle": "^7.9",
    "laravel/framework": "^11.0",
    "laravel/tinker": "^2.9",
    "shopify/shopify-api": "^5.0"
  },
  "require-dev": {
    "fakerphp/faker": "^1.23",
    "laravel/sail": "^1.32",
    "mockery/mockery": "^1.6",
    "nunomaduro/collision": "^8.0",
    "phpunit/phpunit": "^10.5",
    "spatie/laravel-ignition": "^2.0"
  }
}

Replace bootstrap/app.php with

<?php
// bootstrap/app.php (excerpt)
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up'
    )
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
          'shopify.auth' => \App\Http\Middleware\EnsureShopifySession::class,
          'shopify.installed' => \App\Http\Middleware\EnsureShopifyInstalled::class,
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })
    ->create();

Run:

php artisan route:clear
php artisan optimize:clear
php artisan test

11-12

{
  "require": {
    "php": "^8.2", 
    "ext-xml": "*",
    "ext-zip": "*",
    "doctrine/dbal": "^3.7",
    "guzzlehttp/guzzle": "^7.9",
    "laravel/framework": "^12.0",
    "laravel/tinker": "^2.9",
    "shopify/shopify-api": "^5.0"
  },
  "require-dev": {
    "fakerphp/faker": "^1.23",
    "laravel/sail": "^1.3",
    "mockery/mockery": "^1.6",
    "nunomaduro/collision": "^9.0",
    "phpunit/phpunit": "^10.5",
    "spatie/laravel-ignition": "^2.0"
  }
}

Congrats, welcome to Laravel 12 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants