Amazon Linux2 上 PHP Yaml 関数を利用する方法
2020-09-01
2020-09-01
対応経緯:
ある案件で、以下の関するが必要になっていました。yaml_parse_file,yaml_emit_file
ここで、導入方法を説明させていただきます。
現象:
Amazon Linux2のEC2に以下のコマンドを実行しますと、
[Error: Nothing to do] エラーが発生されます。
```
# yum install php-pecl-yaml
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
35 packages excluded due to repository priority protections
No package php-pecl-yaml available.
Error: Nothing to do
```
解決方法:
PHP 5.4 の場合
以下のコマンドを実行しましょう
```
# amazon-linux-extras install -y epel
# yum install php-pecl-yaml
```
結果:
```# yum info php-pecl-yaml
Installed Packages
Name : php-pecl-yaml
Arch : x86_64
Version : 1.1.1
Release : 5.el7
Size : 59 k
Repo : installed
From repo : epel
Summary : Support for YAML 1.1 serialization using the LibYAML library
URL : http://code.google.com/p/php-yaml/
License : MIT
Description : The YAML PHP Extension provides a wrapper to the LibYAML library. It gives the
: user the ability to parse YAML document streams into PHP constructs and emit PHP
: constructs as valid YAML 1.1 documents.
```
PHP 7.* の場合
以下のコマンドを実行しましょう
```
# amazon-linux-extras install -y epel
# yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# yum install php-pecl-yaml
```
結果:
```
# yum info php-pecl-yaml
Installed Packages
Name : php-pecl-yaml
Arch : x86_64
Version : 2.1.0
Release : 1.el7.remi.7.2
Size : 120 k
Repo : installed
From repo : remi-php72
Summary : PHP Bindings for yaml
URL : https://pecl.php.net/package/yaml
License : MIT
Description : Support for YAML 1.1 (YAML Ain't Markup Language) serialization using the
: LibYAML library.
:
: Documentation: http://php.net/yaml
:
: Package built for PHP 7.2.
```