Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

docker: wordpress: Call to undefined function yaml_parse_file()

617 views
Skip to first unread message

SuperTex

unread,
Jul 29, 2020, 5:26:33 AM7/29/20
to
$ curl http://localhost:8000

Among other things, appears:

Fatal error: Uncaught Error: Call to undefined function
yaml_parse_file() in /var/www/html/wp-content/plugins/mytest/main.php

I suppose you need to install the php-imap extension (or something similar).
How you do it?

Here is my docker-compose.yml file:

version: '3.3'

services:
db:
image: mysql:5.7
volumes:
- dbdata:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress

wordpress:
container_name: mytestplugin
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
- .:/var/www/html/wp-content/plugins/mytest

volumes:
dbdata:

Arno Welzel

unread,
Jul 29, 2020, 6:50:07 AM7/29/20
to
SuperTex:

> $ curl http://localhost:8000
>
> Among other things, appears:
>
> Fatal error: Uncaught Error: Call to undefined function
> yaml_parse_file() in /var/www/html/wp-content/plugins/mytest/main.php
>
> I suppose you need to install the php-imap extension (or something similar).

No - YAML has nothing to do with IMAP. YAML is handled php-yaml.

If you created this plugin yourself you should think about using plain
PHP files for configuration instead of YAML. Developing WordPress
plugins which depend on the YAML extension is not a good idea.


--
Arno Welzel
https://arnowelzel.de

SuperTex

unread,
Jul 29, 2020, 10:07:33 AM7/29/20
to
Il 29/07/20 12:49, Arno Welzel ha scritto:
I apologize.
I meant php-yaml extension (or something similar).

But can't you just install php extensions in docker/wordpress?

Jerry Stuckle

unread,
Jul 29, 2020, 10:33:32 AM7/29/20
to
PHP extensions are installed in PHP, not Wordpress. Only a system
administrator can do that.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================

Arno Welzel

unread,
Jul 30, 2020, 9:40:30 AM7/30/20
to
SuperTex:
See this:

<https://stackoverflow.com/questions/49864132/adding-php-extensions-using-docker-compose>

But anyway: relying on php-yaml is not a good idea if you ever want to
use your WordPress plugin anywhere outside your own local docker setup.

SuperTex

unread,
Aug 1, 2020, 10:33:28 AM8/1/20
to
Il 30/07/20 15:40, Arno Welzel ha scritto:
-- SNIPPET ---
wordpress:
dockerfile: extensions
#image: wordpress:latest
--- END SNIPPET ---

$ docker-compose build
The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.wordpress: 'dockerfile'

SuperTex

unread,
Aug 1, 2020, 10:35:02 AM8/1/20
to
Il 29/07/20 16:33, Jerry Stuckle ha scritto:
>
> PHP extensions are installed in PHP, not Wordpress.  Only a system
> administrator can do that.

The admin of?
Of my pc?
o_O

Arno Welzel

unread,
Aug 1, 2020, 10:40:15 AM8/1/20
to
SuperTex:
You should read the ANSWERS there and not the QUESTION.

Jerry Stuckle

unread,
Aug 1, 2020, 5:11:37 PM8/1/20
to
The admin of whatever system your wordpress is running on. For a Unix
system you would need root privileges.

Arno Welzel

unread,
Aug 2, 2020, 12:01:26 AM8/2/20
to
Jerry Stuckle:

> On 8/1/2020 10:34 AM, SuperTex wrote:
>> Il 29/07/20 16:33, Jerry Stuckle ha scritto:
>>>
>>> PHP extensions are installed in PHP, not Wordpress.  Only a system
>>> administrator can do that.
>>
>> The admin of?
>> Of my pc?
>> o_O
>
> The admin of whatever system your wordpress is running on. For a Unix
> system you would need root privileges.

The OP uses Docker. There is no "admin" for a Docker setup.

SuperTex

unread,
Aug 2, 2020, 3:44:16 AM8/2/20
to
Il 02/08/20 06:01, Arno Welzel ha scritto:
> The OP uses Docker. There is no "admin" for a Docker setup.

In fact, it seems strange to me

SuperTex

unread,
Aug 2, 2020, 3:53:36 AM8/2/20
to
Il 01/08/20 16:40, Arno Welzel ha scritto:
> You should read the ANSWERS there and not the QUESTION.

E.g.:
https://stackoverflow.com/a/49875802

Maybe I didn't understand it?

Arno Welzel

unread,
Aug 2, 2020, 5:49:53 AM8/2/20
to
SuperTex:

> Il 01/08/20 16:40, Arno Welzel ha scritto:
>> You should read the ANSWERS there and not the QUESTION.
>
> E.g.:
> https://stackoverflow.com/a/49875802

Exaclty.

> Maybe I didn't understand it?

No, you just did not do what they said:

#remove this
#dockerfile: extensions
#image: php:7-fpm
#change with build ...

Then, add Dockerfile file to the docker/php folder:

FROM php:7-fpm

RUN apt-get update && apt-get install -y \
libicu-dev \
&& docker-php-ext-install \
intl \
&& docker-php-ext-enable \
intl

Of course you have to adapt this to your needs (yaml instead of intl and
you don't need libicu-dev).

SuperTex

unread,
Aug 2, 2020, 9:28:41 AM8/2/20
to
Il 02/08/20 11:49, Arno Welzel ha scritto:
> No, you just did not do what they said:
>
> #remove this
> #dockerfile: extensions
> #image: php:7-fpm
> #change with build ...
>
> Then, add Dockerfile file to the docker/php folder:
>
> FROM php:7-fpm
>
> RUN apt-get update && apt-get install -y \
> libicu-dev \
> && docker-php-ext-install \
> intl \
> && docker-php-ext-enable \
> intl
>
> Of course you have to adapt this to your needs (yaml instead of intl and
> you don't need libicu-dev).

--- docker-compose.yml (snippet) ---
wordpress:
#image: wordpress:latest
build: 'docker/php'
--- EOF ---


$ cat docker/php/Dockerfile
FROM php:7-fpm

RUN apt-get update && apt-get install -y \
&& docker-php-ext-install \
yaml \
&& docker-php-ext-enable \
yaml


$ docker-compose build
db uses an image, skipping
Building wordpress
Step 1/2 : FROM php:7-fpm
---> d7f856a7dcc7
Step 2/2 : RUN apt-get update && apt-get install -y &&
docker-php-ext-install yaml && docker-php-ext-enable
yaml
---> Running in e43351dcd302
Get:1 http://deb.debian.org/debian buster InRelease [122 kB]
Get:2 http://security.debian.org/debian-security buster/updates
InRelease [65.4 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://deb.debian.org/debian buster/main amd64 Packages [7906 kB]
Get:5 http://security.debian.org/debian-security buster/updates/main
amd64 Packages [217 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages
[7868 B]
Fetched 8370 kB in 7s (1150 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
lsb-base
Use 'apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
error: /usr/src/php/ext/yaml does not exist

usage: /usr/local/bin/docker-php-ext-install [-jN] [--ini-name file.ini]
ext-name [ext-name ...]
ie: /usr/local/bin/docker-php-ext-install gd mysqli
/usr/local/bin/docker-php-ext-install pdo pdo_mysql
/usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo
pdo_mysql shmop

if custom ./configure arguments are necessary, see docker-php-ext-configure

Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif ffi fileinfo filter
ftp gd gettext gmp hash iconv imap intl json ldap mbstring mysqli oci8
odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc
pdo_pgsql pdo_sqlite pgsql phar posix pspell readline reflection session
shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem
sysvshm tidy tokenizer xml xmlreader xmlrpc xmlwriter xsl zend_test zip

Some of the above modules are already compiled into PHP; please check
the output of "php -i" to see which modules are already loaded.
ERROR: Service 'wordpress' failed to build: The command '/bin/sh -c
apt-get update && apt-get install -y && docker-php-ext-install
yaml && docker-php-ext-enable yaml' returned a non-zero
code: 1

Jerry Stuckle

unread,
Aug 2, 2020, 2:22:53 PM8/2/20
to
What's not clear to me is is the OP trying to run this on his own system
(bad idea) or on a hosting service?

I'm not at all familiar with Docker, so I don't know which OS version of
PHP et. al. he's running.

J.O. Aho

unread,
Aug 2, 2020, 3:39:26 PM8/2/20
to
On 02/08/2020 20.22, Jerry Stuckle wrote:
> On 8/2/2020 12:01 AM, Arno Welzel wrote:
>> Jerry Stuckle:
>>
>>> On 8/1/2020 10:34 AM, SuperTex wrote:
>>>> Il 29/07/20 16:33, Jerry Stuckle ha scritto:
>>>>>
>>>>> PHP extensions are installed in PHP, not Wordpress.  Only a system
>>>>> administrator can do that.
>>>>
>>>> The admin of?
>>>> Of my pc?
>>>> o_O
>>>
>>> The admin of whatever system your wordpress is running on.  For a Unix
>>> system you would need root privileges.
>>
>> The OP uses Docker. There is no "admin" for a Docker setup.
>>
>>
>
> What's not clear to me is is the OP trying to run this on his own system
> (bad idea) or on a hosting service?
>
> I'm not at all familiar with Docker, so I don't know which OS version of
> PHP et. al. he's running.

The mysql 5.7 docker image is based on debian 10 if using the latest
released image. It will provide PHP 7.3 according to
https://packages.debian.org/buster/php/php

--

//Aho



Arno Welzel

unread,
Aug 2, 2020, 7:50:51 PM8/2/20
to
SuperTex:

[...]
> error: /usr/src/php/ext/yaml does not exist

Hmm - seems the php source php:7-fpm does not provide yaml.

After checking <https://www.php.net/manual/en/yaml.installation.php> I
realized this is a PECL extension which has to be built similar to this
procedure:

<https://stackoverflow.com/questions/44097266/add-yaml-extension-to-php-on-using-official-alpine-docker-image>

I'm sorry that I don't have a definitive solution, but hopefully you get
the idea to do more research on your own.

SuperTex

unread,
Aug 3, 2020, 3:39:30 AM8/3/20
to
Il 02/08/20 20:22, Jerry Stuckle ha scritto:
>
> What's not clear to me is is the OP trying to run this on his own system
> (bad idea) or on a hosting service?

My system.

> I'm not at all familiar with Docker, so I don't know which OS version of
> PHP et. al. he's running.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
$ php -v
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
2, Copyright (c) 2002-2020, by Derick Rethans
$ docker run wordpress php -v
PHP 7.4.8 (cli) (built: Jul 9 2020 23:12:51) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies

Arno Welzel

unread,
Aug 3, 2020, 5:12:45 AM8/3/20
to
SuperTex:

> Il 02/08/20 20:22, Jerry Stuckle ha scritto:
>>
>> What's not clear to me is is the OP trying to run this on his own system
>> (bad idea) or on a hosting service?
>
> My system.
>
>> I'm not at all familiar with Docker, so I don't know which OS version of
>> PHP et. al. he's running.
>
> $ lsb_release -a
[...]

The *host* system is irrelevant for the system inside the Docker image.

Docker composition means to use an existing image which provides the
runtime environemnt and then adding your own software to it. It's
similar to build a virtual machine, just a more lightweight solution.
0 new messages