0

I am following the installation of Basics of YAML Parsing in PHP to install YAML for PHP in Fedora 20.

I went through all these steps:

wget http://pecl.php.net/get/yaml-1.1.0.tgz
tar -xvzf yaml-1.1.0.tgz
cd yaml-1.1.0
phpize
./configure && make && make install

But the last one does not work:

# ./configure && make && make install
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
.../...
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable LibYAML suppot... yes, shared
checking for yaml headers... not found
configure: error: Please install libyaml

As I get the "Please install libyaml", I checked whether it is installed... and it is!

# yum list installed | grep yaml
libyaml.x86_64                         0.1.6-1.fc20                    @updates 
yaml-cpp03.x86_64                      0.3.0-4.fc20                    @anaconda

And of course if I create a php file with a call to yaml_parse_file(), I get the error:

Fatal error: Call to undefined function yaml_parse_file() in XXXfile on line YYY

What can be missing?

2 Answers 2

2

You should install libyaml-dev, not libyaml. On CentOS, I installed it with sudo yum install -y libyaml-devel.x86_64.

[vagrant@localhost yaml-1.2.0]$ yum search libyaml
============================================
N/S Matched: libyaml
============================================
libyaml-devel.i686 : Development files for LibYAML applications
libyaml-devel.x86_64 : Development files for LibYAML applications
libyaml.i686 : YAML 1.1 parser and emitter written in C
libyaml.x86_64 : YAML 1.1 parser and emitter written in C
1
  • 1
    It's in powertools (for Centos 8 and related distros anyway). sudo dnf --enablerepo=powertools install libyaml-devel Commented Oct 2, 2023 at 23:43
0

Oh, this wasn't intended to end like this, but I found a solution through Howto Install with Pecl documentation in Code Google:

  • Install LibYAML using your favorite method. For example on a Ubuntu machine sudo apt-get install libyaml-dev will get what you need.
  • sudo pecl install yaml-beta
  • Edit your php.ini settings and add extension=yaml.so
  • See if it worked with php --re yaml

As I am on Fedora, I had to use a slightly different approach:

# yum search yaml | grep -i php
php-symfony-YAML.noarch : The Symfony YAML Component
php-pecl-yaml.x86_64 : PHP Bindings for yaml
php-symfony-yaml.noarch : Symfony Yaml Component
php-symfony2-Yaml.noarch : Symfony2 Yaml Component
php54-php-pecl-yaml.x86_64 : PHP Bindings for yaml
php56-php-pecl-yaml.x86_64 : PHP Bindings for yaml
syck.i686 : YAML for C, Python, and PHP
syck.x86_64 : YAML for C, Python, and PHP
syck-php.x86_64 : YAML module for php

So I installed php-pecl-yaml.x86_64:

# yum install php-pecl-yaml.x86_64

I added the line into my php.ini file, restarted apache just in case and now I get a good output from:

# php --re yaml
Extension [ <persistent> extension #16 yaml version 1.1.1 ] {

  - Dependencies {
    Dependency [ date (Optional) ]
  }

  - INI {
    Entry [ yaml.decode_binary <ALL> ]
      Current = '0'
    }
    Entry [ yaml.decode_timestamp <ALL> ]
      Current = '0'
    }
    Entry [ yaml.output_canonical <ALL> ]
      Current = '0'

    .../...

    Function [ <internal:yaml> function yaml_emit_file ] {

      - Parameters [5] {
        Parameter #0 [ <required> $filename ]
        Parameter #1 [ <required> $data ]
        Parameter #2 [ <optional> $encoding ]
        Parameter #3 [ <optional> $linebreak ]
        Parameter #4 [ <optional> array $callbacks ]
      }
    }
  }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .