What is Laravel?
Laravel is a relatively new PHP framework which uses the MVC architecture.
Why use Laravel?
Good question. Lately I’ve been looking into PHP frameworks to start a personal project of mine. In my last work project I used CodeIgniter, which was great, but I think it has room for improvement. CodeIgniter worked great for what I needed it to do for me, it was really easy to learn and easy to move into production. After trying Laravel though I feel like Laravel is a few steps ahead of the framework game.
Laravel is very well documented and easy to learn also. It is open source and released under the MIT license. There are many tutorials and screencasts on Laravel so the average web developer should have no troubles getting started on a project.
Tell me more!
You got it! Laravel uses a template system called Blade. Blade provides an easy and clean way to display php variables to your application/page. Blade also comes with some very handy functions such as forelse and unless. Example, in php if you wanted to loop through an array and display its contents you do the regular foreach. But if you wanted to display something else if the array was empty you would need to nest the foreach in an if statement and using proper formatting it gets messy quickly, that’s where forelse comes in. Forelse is a Blade function that will act like php foreach statement unless the array is empty then it gets directed to the @empty statement. This is structured the same way as an if else statement so it looks much cleaner. Check out the Blade documentation for other great control structures.
Another great feature is the Eloquent ORM. This enables you to create simple CRUD statements of a database table with a single line. You’ll have to watch a video on it to see it’s real power but it’s worth using Laravel for that feature alone considering how much time it will save.
Then there is Fluent’s database access. This is much like CodeIgniter’s Active Record implementation but all the same it is a great way of writing database queries.
If you’re starting a PHP project, check out Laravel, you’ll be glad you did.