I was requested to create one little form for my father-in-law who runs a online radio in his free time. The feature is called „Wunschbox“ so basically an input form were the listeners of the radio can leave their request for a certain song. The admins of the radio should be provided with the list of incoming requests and mark them as „done“ (=played on the radio). Sure, not a problem.
Right after creating the project in PHPStorm I wondered if I should just continue in basic PHP or use a cool and fancy framework for this. I love working with frameworks and as I work with Magento as daily business – which provides a big toolset – I wondered if there was something out there that would please my requirements for this small project. It would have taken me about one hour to hack these two pages together but I decided to ask that question on twitter and got some replies. My little journey started.
TL;DR: I was looking for good ways to create a small web-app. After trying Silex and Lumen I decided to go back to basic PHP and finally to TDD.
Looking for the better
I started googling and one of the first frameworks that popped up was Silex which was also recommended in the first replies on twitter.
Silex is a PHP micro framework based on Symfony2 Components. I knew Silex a bit from digging into Bolt CMS some weeks ago. Also the first replies on twitter recommended Silex. So I added it via composer and got started. After adding the Symfony Form Component as a new dependency to my repository it had about 19M in size. That felt just wrong for my little small web-app and would have been an overkill. Meanwhile some new Tweets about Lumen (which I didn’t know before) arrived and I decided to have a look at it, as the website seemed pretty promising.
Lumen is a PHP micro-framework by Laravel. It can also be installed quite easily via composer. You can easily create new projects via command line by calling lumen new projectname. That’s what I did and I found myself again in a project folder with 20MB. The structure looked good but I didn’t want to continue at this point. Again: It was way too much and too big.
The better: Keep it simple – back to basic PHP
Silex and Lumen are really cool Frameworks (as far as I can tell from testing them both for about 30 Min.). But both of them felt just way too big for my two small PHP pages. At this point I reminded myself about some basic principles and one of them was: Keep it simple & stupid. In no way both of these two frameworks which had about 20M each were simple enough for my need as I expected my small web-app to have a few Kilobyte of Code. So I started with the frontend and created the first form in basic HTML. After that, I went to bed.
I tweeted my findings: „Conclusion after 1h of trying Silex and Lumen (which are awesome btw!): I should stick to my own principles and keep it simple > Basic PHP“.
I woke up in the moring with a reply from Vinai on twitter (thanks for that!) who recommended also basic PHP plus TDD!
I didn’t think of creating this „app“ in a TDD way, but the size of the project was just perfect for REAL TDD! So I set up phpunit for my two pages and wrote the first test(s) this morning. At this time I have 6 tests, 2 classes (one for the application + one test class) and that basic HTML form from last night. Nothing big, I know. But I’m really happy with it.
Thanks for the inspiration, Vinai!
There’s some garden work waiting to be done today but I will continue in the evening.
Why a blogpost?
I found the way of finding and deciding really interesting as well as the factors time and quality related to this.
„That’s cool, but you could have been done with that already“
This was my husbands quote when I told him I’ve set up tests for my small web-app this morning 🙂
Yeah, I know: I already spent way too much time with it. More than I would have initially needed. But I’m really happy with the current state, it’s pretty clean, straight, minimalistic and there were some interesting responses related to it.
Initial time thought to create this little web-app: 1h
Time to give Silex and Lumen a try and tweet about it: 1.25h
Setting up the project, phpunit and writing first tests: 0.75h
Time to write this little blogpost about it: ~0.25h
To be continued.
Time for some garden work now. Really. Looking forward to your thoughts & replies on that.