Putting a Laravel app into production

Just put them into your Envoy.blade.php to make sure they are executed every time you are putting a new version of your application on your production servers.Route Caching: php artisan route:cacheConfig Caching: php artisan config:cacheComposer Autoloader Optimisation: composer install –optimize-autoloaderQueuesSometimes I have the feeling that queue-able Jobs and Notifications are the most underrated features in Laravel..But in fact they are pretty awesome..Think about the following situation: Your customer is placing an order at your Laravel-based web shop and clicked on the “Buy now” button..What is your application going to do?.Probably a hell of things, like for example:Sending a confirmation e-mail to the customerSending a notification to your Slack channelAdding the order to the database(and much more)But while you are doing all this, your user expects to be redirected to a “Order has been placed”-page..Now think about the worst case: The page is loading and loading as there are problems with your e-mail server and after lots of waiting your customer gets a HTTP Error 500 due to a TimeoutException of the mailer class in your application..This would be pretty bad for your shop’s reputation..But even if you look at the normal case where it would take a few seconds to get connected to your SMTP server or to the Slack API your user is waiting those seconds.Laravel’s queue system is designed to get a response to the user as quick as possible and let background workers do the time intensive stuff..And on top Laravel’s Horizon, which is an official open source add-on package for your Laravel app, gives you insight view at your queues and successful and failed jobs.Keep track of your queues and jobs in Laravel Horizon’s handy metrics dashboard.So when something’s wrong with your queues you can directly check for the exceptions that have been thrown by your implementation..No time is wasted and your user won’t see that there is some trouble ongoing behind the scenes..Some e-mails may be delayed but for the user everything is loading rapidly as usual.So definitely make use of those awesome Queueables.LoggingOne last short pointer for you: Shit happens..But when it does, make sure that it will be logged and you can reproduce the error to work on it.. More details

Leave a Reply