简体   繁体   中英

Install older version of Yaml (1.3.1) for PHP 5.5.9

I tried to install yaml by using this commands

 sudo apt-get install php-pear libyaml-dev
 sudo pecl install yaml

But this YAML requires php7.0 and newer version. I use PHP 5.5.9 How can install older version of YAML.

You should change your package repository (For example in Debian/Ubuntu Aptitude repositories), for PHP5 versions and then install that version or YAML.

You can use also Composer for the dependencies management, or the "hardest" way, download the source code and implement by yourself.

echo "deb http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb-src http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list


wget http://www.dotdeb.org/dotdeb.gpg -O- |apt-key add -

apt-get update
apt-get install php-pearl ....

As delboy1978uk suggested I had tried with Symfony

Stevan, check this section, the composer lib can also write as well as read and parse. symfony.com/doc/current/components/yaml.html#writing-yaml-fi‌​les – delboy1978uk

This is my working solution

$arr = array(
               'parameters' => array(
                    'stage' => array(
                    'host' => 'host',
                    'username' => 'username',
                    'password' =>  'password'
                ),
                   'live'=> array(
                       'host' => 'host',
                       'username' => 'username',
                       'password' =>  'password'
                   ),
           )
       );

        $yaml = Yaml::dump($arr, 3);

        file_put_contents('parameters.yml', $yaml);

This code outputs

parameters:
    stage:
        host: sasass
        username: dsdadsd
        password: password
    live:
        host: sasass
        username: dsdadsd
        password: password

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM