Please note that this chapter was written for VERSION 3 of the Laravel PHP Framework.
Hi there! I'm Dayle Rees, and I'm going to be taking you on a magical journey into the world of Laravel! Okay on second thoughts that sounds really cheesy. You see this is my first book, so I am gonna be a little rusty at all the posh literary stuff. So if you like straight talking, and being “spoken” to like a real human being then boy are you in for a treat!
You might be asking yourselves “So why should I trust this guy to teach me Laravel? He isn't even an experienced author!”
Well what I lack in experience, I make up for in enthusiasm. I am a huge fan of web development, and the tools and tricks that save us time or make our jobs a lot easier. Laravel fills both of those requirements, and is one of the most useful pieces of software I have ever discovered. In fact my enthusiasm and passion for the framework, that can only be rivalled by the framework author himself has led to me being included as a member of the Laravel core team and “Council” as we like to call it, sounds fancier right?
Being on the Laravel Core team grants me certain privileges such as being notified of new ideas and planned additions to the framework, and by contributing to the framework I am constantly in touch with its forever improving code base. This puts me in a great position to keep the book up to date, which I intend to do with every future release of the framework.
Although I despise going off-topic, it seems compulsory to have a short paragraph about the author within books of this kind, so let's keep it short and sweet. I live on the coast of Wales (that's a country on the side of England for you Americans) and I work for a large public sector organisation in Aberystwyth. In my spare time I am highly involved with the Laravel framework. Oh and as I said before, I don't claim to be a literary genius, let's be honest my writing is gonna suck, it's not gonna be all fancy like those other coding books. I will be 'talking' to you like a real person, you might actually talk back too, we will see. Hopefully my passion for Laravel will make up for my common English (to be fair, I am a Welshman). You don't need to know anything more about me though, let's switch our focus to Laravel.
Laravel is a breath of fresh air in the world of PHP. The PHP programming language is generally quite renowned for its ugly function names, and while we PHP developers have learned to love it, the syntax can be a little ugly compared to some modern Japanese languages. Hi Ruby!
Fortunately Laravel changes this, in fact.. I believe that the Laravel syntax (which granted builds on PHP's own) is so expressive and neat that I find it much easier to read than Ruby. It's not too compact, and while it won't read like an English sentence, it will read like poetry that can only be seen by the eyes of a programmer.
But Dayle..
You say, suddenly worried that your money could have been better spent on some mind numbing fun juice.
Laravel is a framework, not a language!
It's true, you got me. Laravel may not be a language, but it doesn't need to be. We love PHP, come on, let's be honest, we put up with its ugliness, we enjoy typing all those brackets and semi-colons. Laravel simply adds the short-cuts, or a code disguise on top to make the experience so much sweeter.
I think that the pleasure of working from the framework is brought on by its expressive methods which are consistent throughout the framework. Str::upper()
Try to tell me you don't know what this does, try to tell me it doesn't make sense.
I can't.
Yep, I thought so. Well I could jabber on all day about everything that makes Laravel wonderful. Let's see, there's Eloquent, the best ORM I have ever seen. It was what first brought me to the framework.
The option of using closures to route, but only if you want to. I think they look great!
Not having to load libraries before using them, yes.. you heard me right. You will see this in action later.
No there are far too many wonderful features to explain here, I think it would be best if we dived in and started learning, after all.. if you spent your money on this instead of mind numbing juice, you must already have had your interests peaked by the framework right? Onwards!
My books are available online for free to encourage learning. However, if you'd like for me to keep writing, then please consider buying a digital copy over at Leanpub.com.
It's available in PDF, ePub, and Kindle format, and contains a bunch of extras that you won't find on the site. I have a full-time job, and I write my books in my spare time. Please consider buying a copy so that I can continue to write new books from the comfort of my sofa!