1

I am running into an issue when i log into the docker container and run

php artisan migrate --seed

I've had this working before so i'm not sure why this is happening:

Opis\Closure\SerializableClosure implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)

In order this is what i run:

FROM MAC: composer install FROM MAC: sail up -d FROM MAC: sail exec container-id bash FROM CONTAINER: npm install FROM CONTAINER: php artisan migrate --seed

The container runs on PHP 8.1 with MySql on ubuntu. Composer install worked from outside the container to create the vendor folder, here is the composer.json if it's any help:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^7.3|^8.0",
        "ext-dom": "20031129",
        "darkaonline/l5-swagger": "^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.40",
        "laravel/sanctum": "^2.11",
        "laravel/tinker": "^2.5"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^2.10",
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "composer/package-versions-deprecated": true
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

and docker-compose:

# For more information: https://laravel.com/docs/sail
version: '3'
services:
    acklams-api:
        build:
            context: ./vendor/laravel/sail/runtimes/8.0
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.0/app
        ports:
            - '${APP_PORT:-80}:80'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - acklams-mysql
    acklams-mysql:
        image: 'mysql:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        volumes:
            - 'sailmysql:/var/lib/mysql'
        networks:
            - sail
        healthcheck:
          test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
          retries: 3
          timeout: 5s
networks:
    sail:
        driver: bridge
volumes:
    sailmysql:
        driver: local

I can't be sure but i think it should be installing php 8.0 not 8.1, the image: ./vendor/laravel/sail/runtimes/8.0 ?

Below is an image of what i see in the container, i run php -v which shows 8.1 instead of 8.0, and the error at the end when i try to migrate:

enter image description here

EDIT

I noticed it had installed 8.1 and 8.0, so i just switched and it now works. Weird how that just randomly started happening.

MMMWeirdo
  • 187
  • 1
  • 13
  • 1
    @MaikLowrey try what mate? You just quoted me? I was saying that the docker compose has the context to 8.0 but when i run php -v it shows 8.1 and i think this may be why the error is happening. So any idea why it's installing the incorrect php version? - i also added a screenshot – MMMWeirdo Jan 20 '22 at 10:20
  • 1
    Inside the container, that's where it's installed php 8.1 even though the docker file says 8.0 – MMMWeirdo Jan 20 '22 at 10:31
  • https://github.com/cakephp/cakephp/pull/15538 and https://zubair.dev/blog/how-closures-are-serialized-in-laravel-using-opis-closure-package – Maik Lowrey Jan 20 '22 at 10:34
  • 1
    I noticed it had installed 8.1 and 8.0, so i just switched and it now works – MMMWeirdo Jan 20 '22 at 10:52
  • "try it" that was what I meant earlier. – Maik Lowrey Jan 20 '22 at 10:55

1 Answers1

1

I noticed it had installed 8.1 and 8.0, so i just switched and it now works

MMMWeirdo
  • 187
  • 1
  • 13