Larave 9

The Laravel Ecosystem 2022

Introduction

Like with any subject in life, when you first start learning about something, the huge amount of different names and terminology can feel pretty overwhelming. As you’re scrolling through different websites, guides, videos, and forums, you’ll come across a huge range of product names, acronyms, and general answers that assume you already have knowledge about a given subject.

This is exactly how I felt when I first started learning Laravel.

As a developer who works primarily on Laravel applications, I feel spoilt for choice! The ecosystem and the number of first-party packages that are available to us help make our lives easier as developers. There’s no need to spend hours scaffolding out authentication, configuring a confusing Webpack config file, or setting API authentication. If the core framework doesn’t handle one of the mundane tasks that we see day in, day out, there’s probably a big chance that there’s a package or service provided by the Laravel team that does.

But as a side effect of having so many packages and services out there, if you’re new to the Laravel world, it can be a bit confusing at first to understand what each one is. You might be sitting there asking yourself “Do I need to use Laravel Sail?”, “Should I use Breeze or Jetstream?” and “What is Echo?”.

So, the aim of this article is to quickly talk about what each of the packages and services is. Hopefully, if you’re new to Laravel, this will give you a brief understanding of the first-party ecosystem so that you can decide when to use one package over another.

Services

The three services that are offered by Laravel are all related to server management and deployment for your applications. Each of them are paid services, but more than make up for the cost in the time that they save you.

1. Envoyer

Envoyer is an online deployment system that you can use to deploy your application to your servers without any downtime.

Do I Need This?

If it’s critical that the application you’re maintaining experiences no downtime, Laravel Envoyer might be for you. It allows you to release your app to your users without them ever realising that it was being released. If downtime doesn’t necessarily matter, you might be okay with just using Laravel Forge (explained next).

2. Forge

Forge is a server management system that you can use to maintain your servers and deploy your Laravel applications. You can simply hook Forge up with your credentials with a server provider (such as AWSDigital Ocean or Linode) and your credentials for your version control (such as GitHubBitbucket or GitLab). From there, you can then create and provision servers, and then deploy your application.

Personally, I love using Forge because it makes it really easy to maintain my servers and push new releases of my websites and applications without any fuss. In the past, I’ve tried provisioning and maintaining servers myself. Of course, I managed to do it, but it was quite time consuming, and as someone who doesn’t enjoy working on servers and infrastructure, it was pretty boring! Moving over to Forge saves me a huge amount of time (and stress!).

Do I Need This?

If you’re going to be building your own Laravel projects and deploying them to a server, of if you’re in charge of deployments and server management at your job, I’d recommend checking Forge out. All of the jobs that you can do with it can be done manually, but the time that you’ll save by using Forge will more than justify the cost. There are also other alternatives out there such as Runcloud, but I love using Forge and find it a great way of helping to support the Laravel core team.

3. Vapor

Vapor is a serverless deployment platform that you can use to deploy your Laravel application to AWS. The cool thing about Vapor is that it allows you to scale your app’s infrastructure to meet your traffic’s needs when it’s needed. This is really useful for applications and systems where you might have spikes in traffic and need to increase your site’s speed automatically.

As a very basic example, let’s say that you have an e-commerce site deployed on traditional servers and you’ve got a constant stream of traffic. Now, let’s imagine that you have a really cool new Laravel e-book that you’re selling and you’ve built up lots of hype ready for its release day. On the release day, you get a huge surge in traffic and this causes your website to get slow (or even worse, completely crash). As you can imagine, this might come across as a bit embarassing and cause a headache because you’ll be rushing around trying to figure out how to speed it up. You may even opt to deploy more servers and get them set up behind your load balancer to divert traffic to. As you can imagine, this could get tedious because you’d then have to get rid of the additional servers after the spike in traffic. Unless you’re the kind of person who loves tinkering with servers, if this is something that happens regularly, you might find this task a bit annoying because it takes you away from doing what we all love doing the most: building cool new things.

This is where Vapor comes in. If you have a project that may sometimes need to scale up relatively quickly to cope with a large surge in traffic, it can do. Then, once the traffic has died down once more, the infrastructure can automatically scale back down until needed again.

Do I Need This?

If you have a project that’s experiencing surges in traffic that your traditional servers might not be able to cope with, you might want to read into Vapor.

If you’re just starting out on a new project, you might not necessarily need to use Vapor. If this is the case, I’d possibly recommend using something like Laravel Forge at first on traditional servers. Then, after you’ve deployed your application, if you’ve found that your application might benefit from automatic scaling, you can consider switching over to Vapor. Of course, this is only my opinion though, and this is something that you (or your team) would need to decide for yourselves on a project-by-project basis.

Packages

Laravel offers a huge amount of first-party packages that can help you to get your application up and running in no time. The majority of the packages are completely free, however, there are a few paid ones.

1. Breeze

Breeze is a starter kit that provides a “minimal, simple implementation of all of Laravel’s authentication features”. It’s a package that you can drop straight into your Laravel projects to get some simple features such as: login, registration, password reset, email verification and password confirmation.

Breeze comes in two different flavours: Blade and Inertia. If you choose to use the Blade version, the views will be built using Laravel’s Blade templating language. However, if you choose to use the Inertia version, the views will be built using Inertia with either Vue or React. No matter which implementation you use, Breeze is styled using Tailwind CSS, so if you’re familiar with it you can get stuck right in with customising it to fit your project’s needs.

Do I Need This?

If you’re looking for a set of simple and lightweight authentication features to use in your application, I’d highly recommend using Breeze. In a fresh Laravel application, you can have it installed and ready to use within a couple of minutes. So, you can stuck right in to building your cool new project, rather than spending your time building out the authentication.

2. Cashier

Cashier is a particularly useful package that you’ll likely use at some point in your Laravel applications. It handles the majority of your boilerplate subscription code that you’d usually need to write yourself when working with Stripe or Paddle. Cashier allows you to set up things like monthly subscriptions for services, one-off payments, and invoicing. It even has some cool functionality that allows you to set up subscription trials for your projects.

If you’re new to web development, it’s possible that you might find Cashier a bit overwhelming at first due to the fact it’s quite large and provides a lot of functionality. However, if you’re a seasoned developer moving over to Laravel, I think you’ll be pleasantly surprised at how easy it is to use.

In the past, I’ve worked on some projects that handled subscriptions, trials and payments manually. As you can imagine, it was pretty scary working on it and I dreaded having to touch that particular piece of code. But, on another project, we used Cashier and I couldn’t have been more pleased. We managed to add the subscriptions, trials and payments system largely without any hassle. The package was straight forward to understand and allowed us to get stuck in pretty much right away.

Do I Need This?

If you’re considering taking payments from your users, whether it be for recurring subscriptions, or one-time payments, I’d highly recommend looking into Cashier. You can definitely communicate directly with the Stripe and Paddle APIs, but the features and helper methods provided by the package save a huge amount of time and are already battle-tested, so you can have confidence that the features will actually work.

3. Dusk

Dusk is a browser automation package that you can use to test your Laravel applications in Chrome (and other browsers). In my opinion, this package is extremely valuable for your projects, especially as they grow. It allows you to write tests that simulate your user’s actions in a web browser. As a basic example, you can tell it to login in to your application, fill out a form and then assert that the expected validation errors were shown when you input some invalid data.

I’ve used it on projects in the past and it’s been really useful in catching bugs that slipped through our JavaScript unit tests and our PHP tests. However, it’s worth noting that these tests can sometimes take quite a while to run in comparison to your unit tests, so you’ll need to make sure that you add them into your development workflow in a way that doesn’t slow you down while waiting for them to run.

Do I Need This?

In my opinion, if you’re building a project that other users are going to be using, I think tests are an absolute must. Therefore, I’d definitely recommend some form of browser testing.

However, as I mentioned, these tests can sometimes take a while to run, and they can also break quite easily if they aren’t set up correctly and you keep changing your app’s UI (user interface). For example, if you’re in the early stages of building your application, it’s likely that your UI is going to be changing fairly often until you get something that is more stable. If you’re in this situation, you might not necessarily need Dusk because it might slow down your progress. But, if you’re application’s UI isn’t likely to drastically change any time soon, I think you’d benefit a huge amount from having some browser tests written using Dusk.

It’s also worth mentioning that if you’d prefer to write your automated browser tests using JavaScript rather than PHP, you might want to check out Cypress.

4. Echo

Laravel Echo is a JavaScript library that makes it super simple to use WebSockets in your Laravel applications. You can use it subscribe to channels and listen for events that you broadcast from your application on the server-side.

If you’re new to web development, you might not be entirely sure what WebSockets are or what they’re used for. So, to understand the value of Echo, let’s take a look at a basic example. Let’s imagine that we have a page that displays a blog post and allows readers to comment underneath. Now, if a reader comments on the post, we’ll want to display that comment for the other readers to see. There are a few different options we could take here:

  1. We could just do nothing. The new comment will show once the reader refreshes the page.
  2. From the JavaScript, we could “poll” the application on the server-side periodically (maybe every 30 seconds) to fetch and load any new comments if there are any.
  3. From the PHP, we broadcast an event and push out data to the JavaScript every time a new comment in stored in the database.

As you can guess, the third option provides the most real-time data for readers and prevents us from having to periodically poll the server even if there aren’t any new comments added.

So, in order to subscribe to channels and listen for specific events that have been broadcast over WebSockets, we can use Laravel Echo. You can definitely write the code to interact with the WebSockets, but using Echo can save you a huge amount of time and effort.

Do I Need This?

If you’re building a Laravel application that might be needing some real-time data to be displayed, I’d definitely recommend checking out Echo.

For myself, as someone who doesn’t particularly enjoy working with JavaScript and prefers working with PHP, I found this library really easy to get set up and start using.

5. Horizon

Horizon is a package that allows you to run your queues and monitor them using the provided dashboard. The main benefits of using Horizon is that you can have a full overview over your application’s queues to ensure that everything is running as expected. If any of your jobs, listeners, notifications, or any other queued item fails, you can check on Horizon to get more information about what has gone wrong and begin debugging.

Do I Need This?

In my opinion, I think Horizon can be an extremely useful package to install in your projects if you’re planning on using the queues. Even if you don’t want to use it for running your queues on the live version of your system, it can be a really useful debugging tool during local development.

6. Jetstream

Jetstream is quite possibly my favourite Laravel package. It’s a starter kit package that provides authentication features similar to Breeze along with two-factor authentication, session management, team management, and a profile page for your user.

If you’re intending on building an application that needs those features, it would likely take you days or weeks (maybe even months if you’re just starting out in web development). But, with Jetstream you get all of these features out the box absolutely free and you can have an initial version of it installed in your fresh Laravel application within minutes.

Similar to Breeze, Jetstream comes in two different flavours: Livewire & Blade and Vue & Inertia. Both of these versions come with styling provided using Tailwind CSS. This means that you can choose which scaffolding you’d prefer, change your config files as needed, and then be building your application extremely quickly.

Do I Need This?

If you’re building an application that’s going to be needing any of the features that Laravel provides, I’d definitely recommend checking out Jetstream. It’s more than just an set of authentication features like Breeze and gives you a much more robust and feature-rich starting point for your system.

However, if you’re not going to be needing all of the extra features that Jetstream provides, you may be better off opting for Breeze. Personally, if I was new to Laravel, I’d probably download Jetstream just to look at the possibilities that it can provide. But I’d probably use Breeze instead until I felt more comfortable building applications. There is a slight, additional learning curve in Jetstream because you might need to have some knowledge in using Livewire or Inertia (with Vue). Although, you don’t necessarily need to know how to use them, it would be useful to know how to use them for it you want to customize the default UI that’s provided. But, Livewire and Inertia are both relatively easy to understand once you’ve tinkered with them a couple of times, so if you’re feeling up to the task, you might benefit from diving right in and using them.

7. Mix

Laravel Mix is a JavaScript package by Jeffrey Way (creator of Laracasts) that makes working with Webpack super easy. If you’re new to web development, you might not be aware that you usually need to “build” your JavaScript and CSS assets for your sites and applications to get them ready for production. For example, you might want to minify your JavaScript and CSS files so that they have a smaller file size and load quickly for your users. To do this, you can use a bundler such as Webpack.

But, using Webpack can often be quite confusing and complex; especially if you’re not regularly needing to look at or update your Webpack config files. Mix allows you to write your config files in a much simpler way that’s easier to maintain and read.

In fact, I actually use Mix in all of my projects. Don’t be fooled by the name; you can use Mix in non-Laravel projects. By default it comes installed in your Laravel applications, but there’s some really easy-to-follow instructions in the documentation that you can follow if you want to install it in any other project.

Do I Need This?

Unless you’re a seasoned veteran with Webpack or intend to use a different type of system to build your assets, I’d highly recommend using Mix. With just two or three lines of config, you can start compiling and minifying yor JavaScript and CSS assets without any knowledge of how Webpack is working under the hood.

Of course, if you have more experience using Webpack and want more granular control, you may opt against using it. However, across all of the projects I’ve worked on during my time as a Laravel web developer around the world, they’ve all always used Laravel Mix.

8. Nova

Nova is a paid package that provides an administration panel for your Laravel applications. It allows you to add admin functionality to your projects that don’t necessarily need a traditional, full CMS (content management system).

For example, I actually use Nova myself for writing all of my blog posts on my site. It provides me with a lightweight and customisable dashboard that I can use to create and edit my blog posts without much hassle. I even use it on some clients’ websites to display their contact form submissions and change the text on their web pages.

I’ve even seen full-blown applications used in commercial settings that were built purely in Nova, so it can be extended quite well if needed.

Do I Need This?

If you’re building a project or site that needs an admin dashboard so that you (or someone else) can edit some parts of your public facing site, Nova can definitely be useful. However, Nova isn’t a necessity in my opinion and there are other options out there, such as building the admin functionality yourself (if there isn’t a lot to it), or using a CMS like Filament or October CMS.

If I was to rebuild my site again from scratch though, I’d definitely opt for Nova again because it saved me a huge amount of time and I love how simple it was to get up and running after downloading it.

9. Octane

Octane is a package that you can use to drastically improve your application’s peformance using Open SwooleSwoole or RoadRunner. As it mentions in the documentation, “Octane boots your application once, keeps it in memory, and then feeds it requests at supersonic speeds”.

I’ve never used Octane in any of my own projects so I can’t give too much of an opinion on how easy it is to set up or use. However, I’ve heard from other developers online that they used Octane in their own projects and saw some amazing performance improvements.

Do I Need This?

In my personal opinion, if you’re just starting out in web development, you likely don’t need to look at Octane just yet. In the future, if you start working on high-performance or time-critical projects, you might want to take a look at it though.

10. Sail

Sail is a command-line interface that you can use to interact with a Docker development environment. You can use it to get your Laravel application up and running with PHP, MySQL, Redis, Mailhog and other services within a few minutes.

If you’ve not got much experience using Docker, Sail can be a great starting point for a getting a development environment set up on your machine. However, you need to make sure that you don’t use it in production, as it’s not optimised for that type of environment.

I actually use Sail myself for setting up my own projects and running them locally. One of the things that I loved about it, was the how fast it was to go from running the installation command to having a site running in my browser. I didn’t need any experience or knowledge using Docker and I didn’t need to spend ages reading through guides on how to get it all working; it just worked.

Do I Need This?

If you’re just starting out with web development, I’d probably recommend using Laravel Sail so that you can get your Laravel applications running on your machine really quickly. If, in the future, you decide that Sail isn’t right for you and that you’d prefer to build your own Docker image or use a different development environment (such as Valet), then you can quickly remove it from your project. Essentially, Sail is just a couple of files that are stored in your project root, so you can easily delete them if you’re not happy with it.

It’s even easier to use Sail if you’re setting up a fresh Laravel application because it’s actually installed by default. You’ll just need to run the installation command to finish the set up.

11. Sanctum

Sanctum is a lightweight package that you can use to add authentication for token-based APIs, mobile apps and SPAs (single page applications). Just like all of the other packages, the set up is really simple and you can have some form of authentication set up pretty quickly.

I’ve used Sanctum in past projects for APIs and I’ve found it useful because you can add “abilities” to the tokens. For example, imagine that your system can be used to create and edit users. If a user wanted to be able to create a token that only allowed them to update a user but not create them, they could define that in the abilities. This means that you can define granular control and authorisation for your tokens. In some projects, this isn’t really needed. However, this can sometimes be a really cool package to use because it cuts down on the amount of time that we’d have had to spend building the API authentication.

Do I Need This?

If you’re building a project that has an API, I think that you’d benefit a huge amount from using Sanctum. Likewise, I also think that you’d benefit from using it if you’re building a SPA or mobile app. However, if you’re not doing any of these, you might not necessarily need Sanctum and might be better off relying on the authentication methods that are provided by something like Breeze or Jetstream.

12. Scout

Scout is a package that you can use to add searching to your Laravel applications. You can use it to implemenet full-text search the AlgoliaMeiliSearch, and MySQL/PostgreSQL drivers.

Similar to Octane, I’ve never actually used this package before so I can’t give a huge amount of information about it. However, from what I’ve heard from other developers, Scout can be a really handy package to have when you have a large amount of data in your database that you want to search. For example, you may want to use Scout to implement a site-wide search in your project or website.

Do I Need This?

In my personal opinion, I don’t think you’ll need to check out Scout if you’re new to web development. However, I do think that it’d be something worth looking at if you’re thinking about adding a search to your code that may need to be quick to run.

13. Socialite

Socialite is a really cool package that lets you communicate with OAuth providers to authenticate your users. For example, instead of using the traditional sign in form on your project like you’d expect, you can provide the functionality for a user to sign in using Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, and Bitbucket.

This can be extremely useful when you want to make registration and signing up for your project seamless. In fact, in a project that I’m currently, I’ve added the functionality to sign in using GitHub, Bitbucket or Google. I was really pleased with how simple it was to get going and how everything just seemed to plug together and work.

Do I Need This?

I wouldn’t necessarily say that Socialite is something that you need to look at if you’re just getting started in web development or Laravel. But, if you’re looking for a fun little side project to immerse yourself in Laravel, I do think that setting up a dummy login form using Socialite and using it to sign in using another OAuth provider can be pretty enjoyable. Or, if you’re thinking of adding OAuth sign ins for your application, you could definitely add the logic yourself to do this. But by using Socialite, it’s much simpler and prevents you from needing to write code that handles OAuth requests.

14. Telescope

Telescope is a package that you can add to your Laravel application to get an overview of most of your application. As mentioned in the documentation, it “provides insight into the requests coming into your application, exceptions, log entries, database queries, queued jobs, mail, notifications, cache operations, scheduled tasks, variable dumps, and more.”.

In fact, Telescope is one of the first things that I install on every new Laravel project that I start. I love the amount of data that it shows me about my system and the insights it gives me.

One of the awesome things about Telescope is that it’s really simple to install and you can even install it in your staging server if you need more insight when debugging bugs or preparing new releases to be deployed. But, if you are going to choose to make Telescope available on your staging or production servers, it’s important that you lock it down so that it cannot be accessed by the public.

Do I Need This?

In my opinion, I’d recommend Telescope to any new users starting out with Laravel. I think it gives you a really useful insight into your application and can help you understand some of the features that are available to you in Laravel.

15. Valet

Valet is another local development environment (like Sail is) that is built for MacOS users. It configures Nginx and DnsMasq on your machine so that you can access your projects in your browser with ease.

You can’t necessarily use Valet as a replacement for Sail because it doesn’t include all the extras that Sail provides, such as a database, redis or Mailhog. However, if you’re willing to spend a bit of time setting up these optional extras yourself on your machine, then Valet is a great option. It’s extremely minimal so it doesn’t use a huge amount of RAM and is really fast in comparison to something like Sail.

In fact, if I don’t always need the optional extras from Sail, I like to use Valet to set up my sites.

The documentation provides some great instructions on how to set up Valet so that you can start building your application right away.

Do I Need This?

In my opinion, if you’re using a Mac and don’t need all of the extras from Sail, I’d highly recommend using Valet. I think it’s a great local development environment and provides a decent starting point for projects.

Conclusion

Hopefully, this post should have given you a brief overview of the Laravel ecosystem and the different first-party services/packages that are available.

Keep on building awesome stuff! 🚀

Credit : ash-jc-allen (Ash Allen) From https://laravel.io