May, 09 2020

Laravel Lessons: Hosting, Deployments & Error Tracking

Finally, we are at the end of this blog series. After you have built a web application using Laravel framework, the next thing is for you to do is deploy the app on a web server so that people can access it. Thats the focus of this lesson.

I have written two articles on how to deploy a Laravel application. The first is for deploying on a VPS and the second id for deploying on a shared hosting server.

- Zero Downtime Deployment With Laravel Envoy and BitBucket

- How To Deploy A Laravel Project On Linux Shared Hosting In 5 Minutes

But there is more to deploying a Laravel application. Lets get started.

Environment Variable

Lets start with our .env variables. In the first lesson, I explained some of these variables and how they are supposed to be changed when the application environment changes.

When you are deploying to a production environment these variables should be something like this:



Error Tracking & Monitoring

Most users who see bugs on your website won't even bother to let you know. You need something to monitor and track errors on your web application and the good news is that Laravel have a lot of them(Flare, Sentry, Bugsnag etc).

Error tacking and monitoring softwares informs you of errors that may occur when users start using your application. They provide you with details of the error, the user involved, the stack traces etc. This will improve your finding and fixing bugs as you don't have to wait for users to report errors, they are already there for you as they happen.

Among these three error monitoring and tracking software services, Sentry is free and thats what we are going to use. Lets add it to our LiteMailer app.

Sentry Installation

Open your Laravel project directory on terminal and run the composer require command.

composer require sentry/sentry-laravel

Now that we have the sentry SDK in our project, lets add the sentry error catching code to our LiteMailer app. Go to app/Exceptions/Handler.php file and add this code inside the report() method :


public function report(Throwable $exception)
   if (app()->bound('sentry') && $this->shouldReport($exception)) 

Now head over to and create an account. After that you need to create a project and add your sentry DNS to your .env file. Like this:


Now we have an error tracker on our app, ready to report any error experienced by our users.

Thats all for now, at least for a beginner, you will learn other things like automated testing, server backup as you continue your journey into your development career.


You can drop your question on the comment section, send me a DM on twitter or send an email.

Join my inner circle newsletter

Be the first to hear about anything I publish, launch, or think is helpful for you. Subscribe here

Hey, have you tried Litehost lately ?

Litehost is a web hosting platform for PHP & Laravel developers with Composer, Git, PHP & CLI pre-installed. Try it now