安装:
1 下载yaml包
wget http://pyyaml.org/download/libyaml/yaml-0.2.2.tar.gz
tar -zxvf yaml-0.2.2.tar.gz
cd yaml-0.2.2/
./configure
make
make install
2,下载php的yaml扩展包
点击官网下载:https://pecl.php.net/package/yaml
tar -zvxf yaml-2.0.4.tgz
cd yaml-2.0.4/
/usr/local/php7/bin/phpize //这里要改成你PHP的安装目录
./configure --with-php-config=/usr/local/php7/bin/php-config //这里也是一样
make
make install
3 php.ini 添加扩展yaml.so
vi /usr/local/php7/lib/php.ini //一样注意目录
extension=yaml.so
4 重启PHP
使用:
//数组转yaml
$yaml = yaml_emit($invoice);
// yaml转数组
$parsed = yaml_parse($yaml);