The PHP YAML extension provides PHP functions for parsing and serializing files and text containing YAML markup.
This extension does not yet support PHP 7.3.
To install the PHP YAML extension on PHP 7.0, PHP 7.1, or PHP 7.2, SSH in to your server as root and first run these commands:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config sudo apt-get -y install libyaml-dev
Next, run the following command:
sudo pecl7.X-sp install yaml
When you receive this prompt:
Please provide the prefix of libyaml installation [autodetect] :
press Enter without entering a prefix. This allows the library's location to be autodetected.
Once installed, create a configuration file for the extension and restart PHP by running the following command as root:
sudo bash -c "echo extension=yaml.so > /etc/php7.X-sp/conf.d/yaml.ini" sudo service php7.X-fpm-sp restart
To install this extension on PHP 5.4, 5.5, or 5.6, first run the following commands as your server's root user:
sudo apt-get install gcc make autoconf libc-dev pkg-config sudo apt-get install libyaml-dev
Next, run the following command:
sudo pecl5.X-sp install yaml-1.3.0
When you receive this prompt:
Please provide the prefix of libyaml installation [autodetect] :
press Enter without entering a prefix. This allows the library's location to be autodetected.
Once installed, create a configuration file for the extension and restart PHP by running the following command as root:
sudo bash -c "echo extension=yaml.so > /etc/php5.X-sp/conf.d/yaml.ini" sudo service php5.X-fpm-sp restart
You can verify the YAML extension is installed by running this command, where X.Y is your app's PHP version:
phpX.Y-sp -i | grep yaml
You should see output similar to the following:
/etc/php7.0-sp/conf.d/yaml.ini, yaml LibYAML Support => enabled LibYAML Version => 0.1.4 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
To uninstall this extension, as root run the commands:
sudo rm /etc/phpX.Y-sp/conf.d/yaml.ini sudo peclX.Y-sp uninstall yaml
Next, restart PHP-FPM with the command:
sudo service phpX.Y-fpm-sp restart