How to Upgrade From Laravel 9.x to Laravel 10.x

The Laravel 10 has been released on Feb 14. Laravel 10 requires a minimum PHP version of 8.1. Read more about the release on the Laravel release notes.

Our Basic Laravel Admin Panel currently has Laravel 9.x, So time to upgrade to Laravel 10.

Laravel Upgrade From 9.x to 10.x

Laravel upgrade involved the following steps.

  • Update PHP version
  • Composer version update
  • Update Composer Dependencies
  • Update composer Minimum Stability
  • Update Docker composer

All the upgrade steps are available on the official Laravel document.


Update PHP version

Laravel 10 requires PHP 8.1.0 or greater. So update your PHP version. If you using the PHP version below 8.1.

Now we will check out the Admin Panel PHP version. The PHP version will display the Admin panel or Laravel default home page

You can also check the PHP version & Laravel versions in the command line busing below the command

PHP version

./vendor/bin/sail php -v

// or

./vendor/bin/sail php --version

//If you not using sail
php -v

Laravel Version

./vendor/bin/sail artisan -v

//or

./vendor/bin/sail artisan --version

//If you not using sail
php artisan --version

Also, you can check the Laravel version on the ./vendor/laravel/framework/src/Illuminate/Foundation/Application.php file.

Our Laravel Admin Panel is using the Laravel sail (Docker development environment). So we need to update the PHP in the docker-compose.yml file. We update it at the end of the step.


Composer version update

Laravel 10 requires Composer 2.2.0 or greater. If you using a lower version, uninstall and install a new version.

You can check your composer version using the below commands

composer -v

composer -vvv about

if you using the sail try below

./vendor/bin/sail composer -v

./vendor/bin/sail composer -vvv about

We already have the composer version above 2.2.0.


Update Composer Dependencies

For Laravel 10, we need to update the following dependencies in our application’s composer.json file

  • laravel/framework to ^10.0
  • spatie/laravel-ignition to ^2.0
  • php to ^8.1

Admin Panel updated below following dependencies

diff --git a/composer.json b/composer.json
index 381f15d..b0be0bc 100644
--- a/composer.json
+++ b/composer.json
@@ -5,12 +5,12 @@
     "keywords": ["framework", "laravel", "boilerplate", "admin panel"],
     "license": "MIT",
     "require": {
-        "php": "^8.0.2",
+        "php": "^8.1",
         "balajidharma/laravel-admin-core": "^1.0",
         "guzzlehttp/guzzle": "^7.2",
-        "laravel/framework": "^9.19",
-        "laravel/sanctum": "^2.14.1",
-        "laravel/tinker": "^2.7",
+        "laravel/framework": "^10.0",
+        "laravel/sanctum": "^3.2",
+        "laravel/tinker": "^2.8",
         "spatie/laravel-permission": "^5.5"
     },
     "require-dev": {
@@ -19,11 +19,11 @@
         "laravel/breeze": "^1.7",
         "laravel/dusk": "^7.1",
         "laravel/pint": "^1.0",
-        "laravel/sail": "^1.0.1",
+        "laravel/sail": "^1.18",
         "mockery/mockery": "^1.4.4",
-        "nunomaduro/collision": "^6.1",
-        "phpunit/phpunit": "^9.5.10",
-        "spatie/laravel-ignition": "^1.0"
+        "nunomaduro/collision": "^7.0",
+        "phpunit/phpunit": "^10.0",
+        "spatie/laravel-ignition": "^2.0"
     },
     "autoload": {
         "psr-4": {

Update composer Minimum Stability

One more change on the composer file. The minimum-stability setting needs to updatestable

"minimum-stability": "stable",

After the composer changes do the composer update

./vendor/bin/sail composer update

Now open the application home page.

If you need an updated welcome page means, copy the https://raw.githubusercontent.com/laravel/laravel/10.x/resources/views/welcome.blade.php and update the resources/views/welcome.blade.php


Update Docker composer

We going to update docker-compose.yml with the latest changes on Laravel.

The latest Laravel sail is using PHP version 8.2. find below the final version of docker-compose.yml

# For more information: https://laravel.com/docs/sail
version: '3'
services:
    laravel.test:
        build:
            context: ./vendor/laravel/sail/runtimes/8.2
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.2/app
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        ports:
            - '${APP_PORT:-80}:80'
            - '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
            XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
            XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
            - redis
            - meilisearch
            - mailpit
            - selenium
    mysql:
        image: 'mysql/mysql-server:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ROOT_HOST: "%"
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 1
        volumes:
            - 'sail-mysql:/var/lib/mysql'
        networks:
            - sail
        healthcheck:
            test:
                - CMD
                - mysqladmin
                - ping
                - '-p${DB_PASSWORD}'
            retries: 3
            timeout: 5s
    redis:
        image: 'redis:alpine'
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sail-redis:/data'
        networks:
            - sail
        healthcheck:
            test:
                - CMD
                - redis-cli
                - ping
            retries: 3
            timeout: 5s
    meilisearch:
        image: 'getmeili/meilisearch:latest'
        ports:
            - '${FORWARD_MEILISEARCH_PORT:-7700}:7700'
        volumes:
            - 'sail-meilisearch:/meili_data'
        networks:
            - sail
        healthcheck:
            test:
                - CMD
                - wget
                - '--no-verbose'
                - '--spider'
                - 'http://localhost:7700/health'
            retries: 3
            timeout: 5s
    mailpit:
        image: 'axllent/mailpit:latest'
        ports:
            - '${FORWARD_MAILPIT_PORT:-1025}:1025'
            - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025'
        networks:
            - sail
    selenium:
        image: 'selenium/standalone-chrome'
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        volumes:
            - '/dev/shm:/dev/shm'
        networks:
            - sail
    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        links:
            - mysql:mysql
        ports:
            - 8080:80
        environment:
            MYSQL_USERNAME: "${DB_USERNAME}"
            MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
            PMA_HOST: mysql
        networks:
            - sail
networks:
    sail:
        driver: bridge
volumes:
    sail-mysql:
        driver: local
    sail-redis:
        driver: local
    sail-meilisearch:
        driver: local

We have successfully upgraded our Admin Panel to Laravel 10.x


Tags: No tags

Comments are closed.