Parsing libconfig files in PHP

I need to read and write variables from a formatted libconfig file in PHP. But I can not find a library for this anywhere. Of course, I know about the C / C ++ library, but we need to write an extension to use it.

Does such a library or extension exist?

+4
source share
1 answer

Using the C or C ++ API detailed in the documentation , write a small program to convert the libconfig file to JSON or XML (or if you feel adventurous, the PHP serialization format), and then use the PHP libraries to work with this output. If the file has not changed, you can even cache the converted form.

You can call external programs from PHP and get output using exec () .

The best solution would, of course, be to write PHP bindings for the library, but depending on how important this library is for your application, this is probably not worth it.

If you look at the format, I would not recommend using regular expressions to parse a file.

-1
source

Source: https://habr.com/ru/post/1403487/


All Articles