From b03dd98472b80edf01725d0f61bb12aaa71309f2 Mon Sep 17 00:00:00 2001 From: Ariful Alam Date: Thu, 14 Mar 2024 23:41:22 +0600 Subject: [PATCH 1/4] Upgrade Laravel version to 11.x --- README.md | 4 ++-- composer.json | 10 +++++----- config/sanctum.php | 5 +++-- docker-compose.yml | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4e71f9d..e9e26f7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Hydra is a zero-config API boilerplate with Laravel Sanctum and comes with excellent user and role management API out of the box. Start your next big API project with Hydra, focus on building business logic, and save countless hours of writing boring user and role management API again and again. -Hydra works with Laravel 10.x and Sanctum 3.x. If you want to work with Laravel 9.x then checkout the 9.x branch. +Hydra works with Laravel 11.x and Sanctum 4.x. For older versions, checkout the branches. - [Hydra - Zero Config API Boilerplate with Laravel Sanctum](#hydra---zero-config-api-boilerplate-with-laravel-sanctum) - [Getting Started](#getting-started) @@ -95,7 +95,7 @@ docker run --rm \ -u "$(id -u):$(id -g)" \ -v $(pwd):/var/www/html \ -w /var/www/html \ - laravelsail/php81-composer:latest \ + laravelsail/php82-composer:latest \ composer install --ignore-platform-reqs ``` diff --git a/composer.json b/composer.json index 189965c..f957cb6 100644 --- a/composer.json +++ b/composer.json @@ -8,18 +8,18 @@ ], "license": "MIT", "require": { - "php": "^8.1", + "php": "^8.2", "guzzlehttp/guzzle": "^7.4.4", - "laravel/framework": "^10.0", - "laravel/sanctum": "^3.2", + "laravel/framework": "^11.0", + "laravel/sanctum": "^4.0", "laravel/tinker": "^2.7" }, "require-dev": { "fakerphp/faker": "^1.9.1", "laravel/pint": "^1.1.0", - "laravel/sail": "^1.15", + "laravel/sail": "^1.26", "mockery/mockery": "^1.4.4", - "nunomaduro/collision": "^7.0", + "nunomaduro/collision": "^8.1", "phpunit/phpunit": "^10.0", "spatie/laravel-ignition": "^2.0" }, diff --git a/config/sanctum.php b/config/sanctum.php index 529cfdc..f1e5fc0 100644 --- a/config/sanctum.php +++ b/config/sanctum.php @@ -60,8 +60,9 @@ return [ */ 'middleware' => [ - 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, - 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, + 'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class, + 'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class, + 'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class, ], ]; diff --git a/docker-compose.yml b/docker-compose.yml index 73d8c98..37558e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,11 +3,11 @@ version: '3' services: laravel.test: build: - context: ./vendor/laravel/sail/runtimes/8.1 + context: ./vendor/laravel/sail/runtimes/8.2 dockerfile: Dockerfile args: WWWGROUP: '${WWWGROUP}' - image: sail-8.1/app + image: sail-8.2/app extra_hosts: - 'host.docker.internal:host-gateway' ports: From c94d6f0737dd1cfba0c192446abc177be3bb41eb Mon Sep 17 00:00:00 2001 From: Ariful Alam Date: Thu, 14 Mar 2024 23:42:39 +0600 Subject: [PATCH 2/4] Remove PHP 8.1 test workflow --- .github/workflows/PHP8.1.yml | 43 ------------------------------------ 1 file changed, 43 deletions(-) delete mode 100644 .github/workflows/PHP8.1.yml diff --git a/.github/workflows/PHP8.1.yml b/.github/workflows/PHP8.1.yml deleted file mode 100644 index 0bb29c5..0000000 --- a/.github/workflows/PHP8.1.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: "PHP 8.1 Tests" - -on: [push, pull_request] - -jobs: - test: - - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php: [8.1] - - name: PHP${{ matrix.php }} - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv - coverage: none - - - name: Install dependencies - run: composer install - - - name: Create Environment file and generate app key - run: | - cp .env.example .env - - php artisan key:generate - - - name: Create database and run migration - run: | - touch database/hydra.sqlite - php artisan migrate - php artisan db:seed - - - name: Execute tests - run: vendor/bin/phpunit From 3cad5bfb0bd59819a2cb993848f69c8e327bb1c2 Mon Sep 17 00:00:00 2001 From: Ariful Alam Date: Thu, 14 Mar 2024 23:42:47 +0600 Subject: [PATCH 3/4] Add PHP 8.3 test workflow --- .github/workflows/PHP8.3.yml | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/PHP8.3.yml diff --git a/.github/workflows/PHP8.3.yml b/.github/workflows/PHP8.3.yml new file mode 100644 index 0000000..22dc68e --- /dev/null +++ b/.github/workflows/PHP8.3.yml @@ -0,0 +1,43 @@ +name: "PHP 8.3 Tests" + +on: [push, pull_request] + +jobs: + test: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [8.3] + + name: PHP${{ matrix.php }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv + coverage: none + + - name: Install dependencies + run: composer install + + - name: Create Environment file and generate app key + run: | + cp .env.example .env + + php artisan key:generate + + - name: Create database and run migration + run: | + touch database/hydra.sqlite + php artisan migrate + php artisan db:seed + + - name: Execute tests + run: vendor/bin/phpunit From da933458a97a9cf723d3272300068fd013034fad Mon Sep 17 00:00:00 2001 From: Ariful Alam Date: Thu, 14 Mar 2024 23:45:04 +0600 Subject: [PATCH 4/4] Update `actions/checkout` to v4 --- .github/workflows/PHP8.2.yml | 2 +- .github/workflows/PHP8.3.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/PHP8.2.yml b/.github/workflows/PHP8.2.yml index 332c9e5..69aac57 100644 --- a/.github/workflows/PHP8.2.yml +++ b/.github/workflows/PHP8.2.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/PHP8.3.yml b/.github/workflows/PHP8.3.yml index 22dc68e..d7db181 100644 --- a/.github/workflows/PHP8.3.yml +++ b/.github/workflows/PHP8.3.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2