to match your purpose, I think the code it in python is better.
I can do programming in python and also connect with mysql database for config,... Or write it directly to file.
This took about 5 hours to make your project done.
Also, if you prefer php, I can do it for you. But it took longer time.