Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add PHP YAML extension? #1826

Open
vistar opened this issue May 6, 2024 · 2 comments
Open

How to add PHP YAML extension? #1826

vistar opened this issue May 6, 2024 · 2 comments
Assignees

Comments

@vistar
Copy link

vistar commented May 6, 2024

Hi!

I need to install php8.2-yaml. I do:
sudo apt-get update

sudo pecl install yaml

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libyaml
docker@cli:/var/www/.docksal$ sudo pecl channel-update pecl.php.net
Updating channel "pecl.php.net"
Update of Channel "pecl.php.net" succeeded
docker@cli:/var/www/.docksal$ sudo apt-get install libyaml
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libyaml
docker@cli:/var/www/.docksal$ sudo pecl install yaml
downloading yaml-2.2.3.tgz ...
Starting to download yaml-2.2.3.tgz (41,276 bytes)
............done: 41,276 bytes
8 source files, building
running: phpize
Configuring for:
PHP Api Version:         20220829
Zend Module Api No:      20220829
Zend Extension Api No:   420220829
Please provide the prefix of libyaml installation [autodetect] : 
building in /tmp/pear/temp/pear-build-root7tI5Es/yaml-2.2.3
running: /tmp/pear/temp/yaml/configure --with-php-config=/usr/local/bin/php-config --with-yaml
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether cc accepts -g... yes
checking for cc option to enable C11 features... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20220829
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking whether to enable LibYAML suppot... yes, shared
checking for yaml headers... not found
configure: error: Please install libyaml
ERROR: '/tmp/pear/temp/yaml/configure --with-php-config=/usr/local/bin/php-config --with-yaml' failed

sudo apt-get install libyaml

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libyaml

and

sudo apt-get install php8.2-yaml

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package php8.2-yaml is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php8.2-yaml' has no installation candidate

Docksal version: v1.17.0
fin version: 1.110.1

@lmakarov
Copy link
Member

lmakarov commented May 7, 2024

The most straightforward way to install a PHP extension is using the mlocati/docker-php-extension-installer tool. The tool takes care of all of the underlying dependencies.

Install the tool

sudo curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o /usr/local/bin/install-php-extensions
sudo chmod +x /usr/local/bin/install-php-extensions

Install the extension

sudo -E install-php-extensions yaml

Confirm the extension installed successfully

php -i | grep yaml

/usr/local/etc/php/conf.d/docker-php-ext-yaml.ini,
yaml
yaml.decode_binary => 0 => 0
yaml.decode_php => 0 => 0
yaml.decode_timestamp => 0 => 0
yaml.output_canonical => 0 => 0
yaml.output_indent => 2 => 2
yaml.output_width => 80 => 80

We plan to include mlocati/docker-php-extension-installer in the next docksal/cli release.

@lmakarov lmakarov self-assigned this May 7, 2024
@vistar
Copy link
Author

vistar commented May 20, 2024

Thanks!
Please add fin restart to this solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants