15 Mai 2012
I may have solid artistic skills, and I also enjoy web development (most of the time), but the sad truth is that I am an awful programmer. I came to web development “the wrong way”, inserting <?php ?> blocks into my HTML code. As any awful developer, I had no idea I was doing something wrong :-)
Until now, that I urgently needed to develop (or rather, re-make from scratch) a not-so-simple online translations system for many of my projects (including Vladstudio.com website and Windy Press books). I started with my usual stuff - one PHP page for one action (like user-add-block.php), but very quickly got buried under my own spaghetti code.
I got depressed (I do so sometimes!), and despite having very stressed deadlines all around, decided to calm down and see how I can improve. I spent weekend learning Python, and it is definitely more beautiful language than PHP, but the time was not perfect for such serious switch, so I started searching for PHP framework to help me do more in less time, and write better code.
Another several days passed, I browsed hundreds of discussions, discovered and carefully reviewed dozens of frameworks. Unfortunately, none of them resonated with me immediately. In case you’re curious, here is the incomplete list of candidates (scroll down if you’re not):
… and this is the incomplete list! In despair, I decided to try again and start from scratch, reinvent my own wheel again, just try and keep my code more organized.
As I was reading through the documentation, the harmony and piece of mind returned to me. Every aspect of the framework is done the way I would do if I was awesome programmer :-)
Ian Landsman (the boss) explains why Laravel is so good:
I’ve come to since find out that Taylor wasn’t really a PHP guy, working primarily in .NET before deciding to pickup PHP a few years back. I think a great deal of why Laravel is so unique is due to that fact. He learned PHP at 5.3+. Most people you see working on PHP frameworks have been around since 4 and before. … Not just the simple thing of not supporting PHP < 5.3, but not knowing PHP < 5.3 means he was unencumbered by all that mental debt :)
Here is what I like about Laravel:
… Head over to your application/config/database.php config file, if you have ever installed a PHP application you will be familiar with this kind of file, you have your database access credentials to hand don’t you? If not go dig them out right now! … Are you back yet?
… Woop, if we take a look at our database the users table has been created successfully. Wait, we made a mistake! (we didn’t, but I like drama and I need an excuse to use rollback)
… DB::table(‘shoes’)->take(10)->get(); Now I want 10 shoes? I should be more worried.. But it’s clear, limiting is very simple!
… We don’t need the first 5 pairs of shoes do we? They are leather shoes, I like to wear skate shoes, very wide feet you see.. Let’s just skip them. DB::table(‘shoes’)->skip(5)->get();
… Relationships are beautiful. No I haven’t gone all soppy. I mean relationships between tables, in Eloquent they are beautiful.
… You see artisan takes the current date, and adds the time in His format to create the file name. The reason for this is that dates are very important to migrations (and single people),…
Now, I have zero experience working with Laravel, and in a month I may update this article with how bad it turned out to work with. But I don’t think it will happen. I really look forward to digging it deeper and doing amazing things with it!