Hi,
I'm upgrading my app dependencies and tried to upgrade lcobucci/jwt to version 4.1.5 (which is also a requirement for
"kreait/firebase-php": "^6.0.0",
Deployment fails with a dependency error, where ext-sodium is missing from GCP (and indeed it's not listed as an available dependency)
lcobucci/jwt package maintainer responded :
https://github.com/lcobucci/jwt/issues/821
###################
ext-sodium is bundled with newer PHP versions since a while (7.2 onwards - see https://wiki.php.net/rfc/libsodium ).
It is reasonable to expect it to be installed: contact GCP support and ask for help there.
###################
So do you think it's possible Google App Engine might support the sodium extension ?
Thomas.
Solved! Go to Solution.
in fact it's not ext-libsodium, but ext-sodium.
But adding it in the "require" section is not enough, you should add it in the config/platform section as well.
I've retried twice, with and without platform statement, and for Google App Engine it's required to have the platform for sodium extension to work, here is the full working composer.json :
{ "name": "rcq/redcrossquest", "description": "French Red Cross yearly fundraising rest backend", "keywords": ["RedCross","CroixRouge","FundRaising"], "homepage": "https://github.com/dev-mansonthomas/RedCrossQuest", "license": "GPL-3.0-or-later", "type": "project", "authors": [ { "name": "Thomas Manson", "email": "cv@mansonthomas.com", "homepage": "http://www.mansonthomas.com/" } ], "require": { "php": "^7.4", "ext-PDO": "*", "ext-bz2": "*", "ext-json": "*", "ext-zip": "*", "ext-sodium": "*", "doctrine/annotations": "^1.13.2", "egulias/email-validator": "3.1.2", "google/apiclient": "^v2.12.1", "google/cloud": "^v0.175.0", "google/protobuf": "^v3.19.4", "google/recaptcha": "^1.2.4", "grpc/grpc": "^1.42.0", "guzzlehttp/guzzle": "^7.4.1", "jolicode/slack-php-api": "^v4.4.1", "kreait/firebase-php": "^6.1.0", "lcobucci/jwt": "^4.1.5", "nesbot/carbon": "^2.56.0", "nyholm/psr7": "^1.5.0", "php-di/php-di": "^6.3.5", "phpmailer/phpmailer": "^v6.5.3", "ramsey/uuid": "^4.2.3", "robmorgan/phinx": "^0.12.10", "sendgrid/sendgrid": "^7.11.4", "slim/php-view": "^3.1.0", "slim/psr7": "^1.3.0", "slim/slim": "^4.9.0", "symfony/http-client": "^v5.3.14", "symfony/validator": "^v5.4.3", "zircote/swagger-php": "^4.2.8" }, "autoload": { "psr-4": {"RedCrossQuest\\": "src/"} }, "config": { "optimize-autoloader": true, "classmap-authoritative": true, "sort-packages": true, "preferred-install": { "*": "dist" }, "platform": { "php": "7.4", "ext-sodium": "7.4" } } }
I would recommend you to file a feature request which would then be evaluated by the App Engine engineering team and depending on the outcome of the evaluation, there would be a decision on whether the extension would be supported or not.
In fact, Sodium is listed as libsodium (that's why I missed it, I was look at the end of the list)
https://cloud.google.com/appengine/docs/flexible/php/runtime#using_php_extensions
I think my issue was that I was including it as :
"require": { "php": "^7.4", "ext-PDO": "*", "ext-bz2": "*", "ext-json": "*", "ext-zip": "*", "ext-sodium": "*",
while I should include it as :
"require": { "php": "^7.4", "ext-PDO": "*", "ext-bz2": "*", "ext-json": "*", "ext-zip": "*", "ext-libsodium": "*",
I'll retry and update this post.
in fact it's not ext-libsodium, but ext-sodium.
But adding it in the "require" section is not enough, you should add it in the config/platform section as well.
I've retried twice, with and without platform statement, and for Google App Engine it's required to have the platform for sodium extension to work, here is the full working composer.json :
{ "name": "rcq/redcrossquest", "description": "French Red Cross yearly fundraising rest backend", "keywords": ["RedCross","CroixRouge","FundRaising"], "homepage": "https://github.com/dev-mansonthomas/RedCrossQuest", "license": "GPL-3.0-or-later", "type": "project", "authors": [ { "name": "Thomas Manson", "email": "cv@mansonthomas.com", "homepage": "http://www.mansonthomas.com/" } ], "require": { "php": "^7.4", "ext-PDO": "*", "ext-bz2": "*", "ext-json": "*", "ext-zip": "*", "ext-sodium": "*", "doctrine/annotations": "^1.13.2", "egulias/email-validator": "3.1.2", "google/apiclient": "^v2.12.1", "google/cloud": "^v0.175.0", "google/protobuf": "^v3.19.4", "google/recaptcha": "^1.2.4", "grpc/grpc": "^1.42.0", "guzzlehttp/guzzle": "^7.4.1", "jolicode/slack-php-api": "^v4.4.1", "kreait/firebase-php": "^6.1.0", "lcobucci/jwt": "^4.1.5", "nesbot/carbon": "^2.56.0", "nyholm/psr7": "^1.5.0", "php-di/php-di": "^6.3.5", "phpmailer/phpmailer": "^v6.5.3", "ramsey/uuid": "^4.2.3", "robmorgan/phinx": "^0.12.10", "sendgrid/sendgrid": "^7.11.4", "slim/php-view": "^3.1.0", "slim/psr7": "^1.3.0", "slim/slim": "^4.9.0", "symfony/http-client": "^v5.3.14", "symfony/validator": "^v5.4.3", "zircote/swagger-php": "^4.2.8" }, "autoload": { "psr-4": {"RedCrossQuest\\": "src/"} }, "config": { "optimize-autoloader": true, "classmap-authoritative": true, "sort-packages": true, "preferred-install": { "*": "dist" }, "platform": { "php": "7.4", "ext-sodium": "7.4" } } }
It did not work for me with PHP 8.2.
Am I the only one?
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.2",
"fruitcake/laravel-cors": "^2.0.5",
"guzzlehttp/guzzle": "^7.2",
"kreait/firebase-php": "^7.2",
"kreait/laravel-firebase": "^5.2",
"laravel/framework": "^9.0",
"laravel/sanctum": "^2.14",
"laravel/tinker": "^2.7",
"league/flysystem-google-cloud-storage": "^3.13",
"nunomaduro/collision": "^6.1",
"ext-sodium": "*",
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^1.0"
},
"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-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"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,
"platform": {
"php": "8.2",
"ext-sodium": "8.2"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
PHP 8.2 flex runtime uses ubuntu22 as base OS and overall other docker image under the hood. I guess it is cause your(and my) problem. I switched back to php8.1 runtime, patched my composer.json with .config.platform section and this particular problem with ext-sodium has gone.
My `app.yaml`:
runtime: php
env: flex
runtime_config:
operating_system: "ubuntu18"
runtime_version: "8.1"
document_root: public
env_variables:
APP_ENV: 'prod'
My `composer.json`:
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": "8.1.*",
"ext-ctype": "*",
"ext-curl": "*",
"ext-grpc": "*",
"ext-hash": "*",
"ext-iconv": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-protobuf": "*",
"ext-sodium": "*",
"ext-tokenizer": "*",
"ext-xml": "*",
"google/cloud-firestore": "^0.1.0",
"grpc/grpc": "^1.38",
"kreait/firebase-bundle": "^5.0",
"openai-php/symfony": "*",
"symfony/console": "6.3.*",
"symfony/dotenv": "6.3.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "6.3.*",
"symfony/runtime": "6.3.*",
"symfony/translation": "6.3.*",
"symfony/yaml": "6.3.*",
"telegram-bot/api": "^2.4"
},
"require-dev": {
"laravel/pint": "^1.10",
"rector/rector": "^0.17",
"symfony/maker-bundle": "^1.50",
"symfony/var-dumper": "6.3.*"
},
"config": {
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},
"sort-packages": true,
"optimize-autoloader": true,
"classmap-authoritative": true,
"preferred-install": {
"*": "dist"
},
"platform": {
"php": "8.1",
"ext-sodium": "8.1",
"ext-hash": "8.1"
}
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "6.3.*"
}
}
}
BTW consider check and list ALL php extensions that your app deps requires in your composer.json
That can be quickly done via command: `composer chack-platform-reqs`
Check my answer, you need to add it to the platform section. (at least, that did the job for me)