dockerdrupalyamlphp-extensionddev

Unable to enable php-yaml for php 8.0 in ddev


After creating directory structure for Drupal9,

ddev config --project-type=drupal9 --docroot=web --create-docroot

i created the project, a Drupal distribution Varbase Starter Kit in this directory using ddev:

ddev composer create Vardot/varbase-project:~9 --no-dev --no-interaction

I did the necessary configurations and changed the name and docroot (note: Varbase uses the directory called docroot instead of web) of the project in config.yaml Then while i was trying to install the distribution via browser i had a warning telling me that PHP extension YAML is missing.

So according to instructions in ddev documentation i added the package to Docker image by adding the following line to config.yaml:

webimage_extra_packages: [php-yaml]

Then in order to enable the extension i created a php directory in .ddev directory and added my configuration with an .ini file that contains the following lines:

[PHP]
extension=yaml.so

I restarted ddev but YAML extension was still not enabled. I checked and saw that php-yaml package was successfully installed but was not enabled. when i list the PHP modules with the command ddev php -m yaml is not listed and i get the following warning:

PHP Warning:  PHP Startup: Unable to load dynamic library 'yaml.so' (tried: /usr/lib/php/20200930/yaml.so (/usr/lib/php/20200930/yaml.so: cannot open shared object file: No such file or directory), /usr/lib/php/20200930/yaml.so.so (/usr/lib/php/20200930/yaml.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

It seems that yaml.so file cannot be found (or accessed?) so it cannot be enabled. How can I fix this?

I'm using Linux Mint (LMDE5) and website is Drupal9 with PHP 8.0, nginx-fpm, mariadb 10.3


Solution

  • The package you want is just php8.0-yaml, and the 8.0 can be automated with the DDEV_PHP_VERSION environment variable, so in .ddev/config.yaml:

    webimage_extra_packages: [php${DDEV_PHP_VERSION}-yaml]

    No additional configuration is required (you don't have to change php configuration) just ddev restart. After you do that you'll see yaml listed in ddev php -i

    See docs