If you’ve read any of my previous posts you know that I’ve just started developing seriously in PHP a bit over a year ago. It was great fun watching my skills progress but now that I’ve gotten some perspective, I feel like the code I’ve written in that time is truly ugly. In my previous post on where to work I mentioned that at my current job I wrote a simple CMS back end for our writers to create their own HTML pages. Well, this process began long before I familiarized myself with MVC or any of the popular frameworks out there. I had heard of Zend but I just thought it was something with a really cool name that I would never have to give a hoot about. Turns out I was wrong.
MVC sounded fantastic and all but I found myself getting lost in the lingo. I’m a hands on kind of learner so telling me all about abstractions, business logic, separation of concerns, and dependency injection left me a bit frazzled. Fast forward to October ’13. My company recently purchased a really, really, really expensive domain name that we have big time plans for. We’ve all agreed that the site built on said uber TLD needs to be second to none (actually, in our ‘widget’ business it’s not hard – lots of companies have garbage websites). With that said, I was posed this question – so, should we build it in wordpress? A few years ago my naive self would have giggled and said OF COURSE! My newly educated self said – would Amazon or Target or, like, *anyone with lots-o-pages with advanced needs *build it in wordpress? No, of course not. So off I go to the internet super highway to bone up on my MVC and PHP frameworks again. It turns out there are way more than even the major players that I had heard of. At any rate, I recalled what my advanced developer friend and compiled for us in CakePHP and decided to give it a go.
CakePHP – OH THE HUMANI…SYNTAX
So, I started down what I had hoped would be a long path with CakePHP. I had done some research and plenty of people had mentioned ‘the learning curve’ but I figured ‘I’ve lived and breathed PHP for the past year, I can do this’. Installation and setting everything up on my local WAMP server went just peachy. So far, so good. Like any logical human being I decided to start out in the documentation from the source itself at cakephp.org. I read up on the basics but, again, I am a hands on learner so tutorial time. CakePHP’s documentation includes a tutorial on setting up a very basic blog with cake. This sounded right up my alley. A few steps in I started to realize I had a problem. Everything seemed to be running just fine but the documentation – well – the documentation kind of sucked. If you find yourself here as a Cake veteran PLEASE do not get up in arms – I’m sure cake is fantastic when you know what you are doing but as a beginner stepping into an MVC framework for the first time it was a head scratcher. It seemed like it was geared toward the experienced framework developer that understood the nuances and just need the general ‘this goes here, invoke it this way, return and parse like this’. But, for a beginner, I needed a lot more hand holding. Plus, as the tutorial went on I realized that sending large amounts of data to methods in arrays was just totally miserable. I’m as big a fan as any one of braces and brackets – but when you’re on your fifth nested array it’s like looking at that horrible 3d art from the 90’s.Being the go-getter that I am I was undeterred. Have you guys heard of this thing called Ruby on Rails? HAHA jk jk jk – I knew about that even before I knew what it actually was. I toyed with that a bit and really enjoyed picking up some Ruby ( I know, in the PHP community that is enough to warrant a stoning ). But, it wasn’t totally practical for me to learn a new language and a framework at the same time. I’d been struggling with the framework part enough as is. And then, as fate might have it, during my PHP vs. Ruby google’s I found it – and by it I mean Laravel.
Laravel – It’s some kind of Panda-Cat-Lemur….thing…
As my search had worn on for a framework with good documentation and support one name kept popping up as new and exciting – it was Laravel. As in most situations in life, finding the thing I wasn’t looking for helped me find exactly what I was looking for. I found that Laravel had good and easier to understand documentation from the start. I was able to get everything setup, including composer (it’s dependency manager), with little to no grief. I had even found some tutorials online that I had planned on working through. On the recommendation of the site, I read through Dayle Rees’s Code Bright book. This thing was a god-send. It was exactly the hand holding I needed to get me through learning a framework and that dude is funny – legitimately. On top of alllll of that – the syntax within Laravel is way less verbose and far more elegant than what I had experienced in cakePHP. Most methods will allow data passed as an array just like Cake but they also allow you just to comma separate things instead of saying array(array(array(“mood”=>”bummed”))). The methods are much more clearly arranged and labeled as well. And, finally, using blade templates IS AWESOME. The ability to strip out from everything including methods made me want to cry tears of unbridled joy.
Full disclosure – I’ve not gone through and developed a full app in Laravel yet. I wanted to write this as a synopsis from the total beginners point of view. With that said, I feel like I’ll be sticking to Laravel for a while. It’s been a pleasure so far to learn and it’s so much more intuitive – for me that is. If you swear by CakePHP, I believe you. Everyone chooses their own tool, it’s what you do with it that really counts. I’m sure there are fantastic projects being done in all of these frameworks and that’s exactly what gets me so excited for my own.