Laravel is awesome. Not just the framework, but its ecosystem. Let me walk you through it and show some of the beauties arround this community.
First of all, I have to say that I don’t participate as much as I want online, but I consume a lot from this community. In fact, I owe a huge amount of skills I have to this community. The first thing that pops up on this topic is Laracasts. As the website says “it’s like Netflix for developers”. I should say that it’s not only about Laravel, but PHP in general.
There is also the #laravel IRC channel on freenode (which is pretty cool), Laracasts Forum, LaravelIO, Larachat Slack Channel, Laravel News (a weekly newsletter about what is trending in the community), Laravel Podcast (where they talk about what is trending in the Laravel community), Laravel Collective (a group that maintains some packages that were extracted from the framework), LaraJobs (a place to find jobs, where I found madewithlove, haha), Matt Stauffer’s blog is also a nice place to read about the trending Laravel features.
I recommend a lot of other resources that I discovered on this community, like: Full Stack Radio (as the name says, a podcast about fullstack stuff, really good!), Dev Discussions, Servers for Hackers. I must have forgotten some pretty good resources, but I’ll try to update this list.
Laravel provides some pretty good tools/features that speed up our development workflow, let’s talk about some of them:
The first thing I should talk about is Laravel’s Homestead. It’s just a vagrant wrapper with a box that has most of the things a modern PHP application needs. Yes, you can still benefit from it even if you don’t use Laravel. It has things like: Ubuntu 14.04, PHP 5.6, HHVM, nginx, MySQL, Postgres, Node (with Bower, Grunt, and Gulp), Redis, Memcached, Beanstalkd, Laravel Envoy, Blackfire Profiler. That being said, the whole point of homestead is that you don’t need to build a VM for each project that you’re working on, you can use the same VM for multiple projects, ’cause it’s all there. Another great point is that everything is already baked inside the VM, so you don’t have to wait for it to provision.
However, I have to say that if your project differs from this setup, don’t hesitate to build your own vagrant box with the tools you need.
Some people say things that I don’t get, like: “Laravel is too good, don’t use it. It might not be arround in the next five years”, what? I really don’t get it. Laravel is an awesome framework, use it wisely.
Laravel is a fullstack framework, it means that it provides a lot of functionality, like: routing, database migrations, MVC structure (a little different from other MVC frameworks out there, I’ll talk about it in a second), authentication, billing service, command bus, pagination, validation, filesystem/cloud storage (same interface for both), an awesome ORM called Eloquent (which is an implementation of the ActiveRecord pattern).
As Elixir’s documentaion says:
It’s a plugin for Gulp with a bunch of useful features like: compile less/sass, compile coffeescript, combine scripts/stylesheets, versioning your assets (so you don’t need to worry about browser cache when you deploy front-end changes), browserify integration (so you can use EcmaScript 6 sintax right now).
One thing I would like to talk about is how Laravel changed the way I code. Taylor suggests in his book From Apprentice to Artisan to get rid of the
app/models folder. That was mind blowing to me. Like, your model is your domain and your domain is not a buch of database tables that interact. Your domain has behaviour. That is pretty good and one of the first benefits I saw when I decided to use this framework.
If you come from a regular MVC framework where your have
app/views folders, you might get a little confused on your first attempt to use Laravel (the version 5.x), but I assure you it will be better. It will feel better.
Laravel ships with a Queues component that you can use to benefit from background jobs. For those who never used it before, think about a registration process with a welcome e-mail being sent at runtime. The user has to wait until the e-mail is sent to get the response of the registration request. When using queues you would just delay the e-mail delivery to background (outside of the request scope), to be executed later or by another service. It would speed up the registration request and your user would still be happy with your welcome e-mail. In fact, he/she would be happier because you didn’t make him/her wait.
It ships with a few queue drivers, like: redis, database, Amazon SQS, Beanstalkd, IronMQ and a “sync” that just executes the “job” at runtime. A good point is that every driver implements the same interface. It means that you can use any of these services to work with queues.
So you are developing an application that has some kind of subscription plan and you have to implement all this payment logic. Well, Laravel has a package for that called Cashier. You can easily integrate Stripe for your application. Reading the documentation you can see how easy it is to integrate.
You want to allow your users to register/login using their social network accounts? You’re going to love Socialite. It handles all that OAuth 1/2 workflows for you and it also abstracts the user data using a common interface, so you don’t have to know that Google returns a
given_name and Facebook returns a
first_name, for example. It integrates with Twitter, Facebook, Google, Github and Bitbucket. Really cool.
This is still fresh at the moment I write this post: Laravel 5.1 is going to provide a websocket integration out of the box! It means that your can add realtime functionalities to your app as easy as implementing an Interface on your backend code and a couple of JS lines on your front-end code. How cool is that? You can see an example at laracasts where Taylor presents this feature.
There are lots of good stuff in the framework that I would like talk about, but this post would get huge. Instead, you can walk arround the documentation and there is a lot of good stuff on Laracasts.
So you found a context in your application that would be faster if it didn’t need to use the whole framework? You can use Lumen which is the official Laravel micro-framework. It is faster than Laravel (and faster than other micro-frameworks, as the main page says), but you still use some of Laravel’s cool features, such as the Eloquent ORM and the Queues Component.
It’s also possible to use some other Laravel’s fullstack functionalities, but if you need some of it you might consider moving to the fullstack framework.
Let’s now talk about some of the goodies Laravel provides for your deployment.
There were times when deploying an application was a pain, with lots of FTP files being sent and failures and so on. One of the first things we have to do to deploy our application is build a server with all the functionalities we need. Laravel has a service for that called Forge.
It handles the creation and provisioning of servers for you. It basically hooks into your cloud provider (such as Amazon, DigitalOcean or Linode) and create your servers so you don’t have to worry about “which version of PHP is there?”, “is mysql installed?” or things like that. Pretty cool. You can even automate your deploys there using git, but Laravel also provides a service for deployments called Envoyer.
While you can have automatic deployment setup using Forge, it’s recommended that you use a dedicated service for that. That is what Envoyer is all about. It makes deploying new code a breeze. It’s zero downtime, so your users won’t face a “maintenance” page while you deploy new stuff.
It also has really cool stuff like cron job monitoring (which is useful, so you get notifications if one of your application’s cron jobs stops working) and application health check. Deploying PHP applications was never as easy as now.
Rocketeer is a tool for automating deploys. It seats side by side with ruby’s Capistrano or python’s Fabric. With that you can easily setup your own deploy process with zero downtime, notifications and so on. Pretty cool!
Laravel also provides another tool for task running called Envoy. With this tool, you can easily run a few tasks on your remote servers or also setup a simple deploy script, as you can see on this Servers for Hackers screencast.
Last but not least, be careful with your application, the framework is just a tool, but you can follow SOLID principles and still benefit from Laravel’s goodies. Take a look into the Contracts package, which is a component used in the framework so you can easily depend on Interfaces to use the framework features and Laravel’s IoC will handle the instantiation of the right objects.
These are just a few goodies that Laravel provides to us. Once you start working with laravel, you notice how good it is and how easy it is to use its features/services.