Skip to content

web - tips and tricks about php filehandling and handling json files

While developing an example for the heartbeat component, i run into problems dealing with file handling in php. The problem comes from race conditions by reading and writing (updating) the same files. I must admit, it still needs some time to solve this problem in a sufficient way, but i'm on it.
Nevertheless, two shiny links where found by my preferred search engine and it would be a shame to not share them.

The first link has the title handling json like a boss in php. The page shows you how to encode and decode json files in php. What i liked very much, it also contains an error handling part. Shame on my side, i was not aware of the jsonlasterror function, now i am :-).

The second link headlines itself PHP File-handling tips and tricks and it contains a lot. I like, that the author puts back the SPLFileObject and SPLFileInfo into the limelight.
Even better, i wasn't aware of the available stream "php://temp". Thank you both!

Translate to de es fr it pt ja

Configuration Format Converter

Since i have to deal with a lot of configuration formats in php- or webapplications, i decided to write a conversion tool.

Today i'm happy to announce the version 1.0.0.

It is a console application (symfony/console based) and provides one command called convert. convert expects two arguemts, source and destination. The command has an option --force if destination already exists.
What do you have to provide as source or destination? For the source, you have to provide a relative path to the source configuration file. For the destination, you have to provide a relative path with file name that should contain the converted source configuration file content.

Since the conversation depends on a component, it is restricted to this capabilities. Good to know, i also maintain that component so if this cli application needs additional features, the component should be extended quite soon ;-).

The command line configuration format converter is available on github.com or via packagist.org.

Since the formater component is using the php array as exchange format between the available formats, you should know that the configuration files are underlying some restrictions. I'm working hard to create a wiki for the convertion component.

Enjoy it and feel free to report bugs or fork it.

Translate to de es fr it pt ja

current Software Components Available On Github And Packagist (Symfony Console Command, IO, Application and Configuration Format Converter)

After getting more and more into the great world of composer based systems, i tried to reuse code from my current and ongoing projects and cast them into separat components.

Right now, the follwing are available: - Symfony Console IO - Influenced by a teammate and by composer, i wanted to have IO object in my console applications. - Symfony Console Command - Since the IO component makes more sense in the command and since, again influenced by teammate and composer, i wanted to have a command code that stops me from repeating myself in different console applications. - Symfony Console Application - The last package from my lab, like the command, this package is a application with my flavor. - Component Configuration Converter - I was getting sick of converting configuration formats from one to another, so i create a component for that. Currently the following formats are available: - YAML - XML - JSON - PHPArray

All Packages are availalbe on github.com and i would be glad if you are going to test them in the real world and add some defects.

Translate to de es fr it pt ja