Skip to main content


Showing posts from May, 2015

Little things can make a difference

Wow, I never expected this much involvement when I created an overview of upcoming conferences this fall. I cannot deny I love Markdown to write simple things and I love simplicity. I use IA Writer to have distraction-free editing power on both my phone and laptop.

iA Writer iA Writer is a minimalist text editor for OS X and iOS developed by Information Architects Incorporated. The idea of iA Writer is "to keep you focused on just writing". iA Writer has been "downloaded 600,000 times by everyone from hobbyist writers to the bestselling author Augusten Burroughs." It is the top selling text editor in the App Store behind Apple's own Pages application. More at Wikipedia
So last night, returning back from php[tek] 2015, I was noting down a small list of upcoming conferences this fall in Markdown. But my memory was a bit fuzzy from the travel I decided to paste it into a Gist on GitHub so I could ask people in my network to inform me about missing even…

popen for cli commands and pipes in php

I got a question today about using commands that pipe output to other commands within PHP applications.

There are two functions in PHP that are perfect for the task: popen and proc_open.

The function "popen" opens a process file pointer, basically you have a pointer during the execution of a process. This functionality is often useful when you have one-way traffic (like piping commands on command line).

The function "proc_open" behaves the same as popen, but gives you access to the input and the output, which makes it very useful for reading and writing as you go along.

So let's say you have logic that generates a crontab entry, you can always do this using the commandline.

/usr/bin/php crontab.php | /usr/bin/crontab But when you want to run it as a complete process, you can go about using exec, shell_exec, passthru or system and fiddle with escapeshellcmd. But often this looks messy and not reusable.

A better approach would be to use "popen". A small…