A Brief Introduction to Laravel Envoy

Laravel Envoy provides you a simple and elegant way to run common tasks on your remote servers. If you have ever used Fabric, Capistrano or other tools for managing remote tasks, you already have an idea how Envoy tasks will look like.

Laravel Envoy Installation

To install Laravel Envoy simply run:

after that, make sure ~/.composer/vendor/bin/envoy  is flagged as executable:

Continue reading A Brief Introduction to Laravel Envoy

Pro tip: Display all validation errors in Blade View

Every Blade View have $errors variable bounded to it unless you set different one by yourself. If you use controller based error handling, you will probably have something like this inside it:

We passed validation errors to the profile view using withErrors() method and inside that view you can display them:

 

Laravel: Model Observers

In the last tutorial I showed you how you can speed up a web application by caching database queries that are executed very often. However, there is a problem. Application will cache the resulted dataset, and in the future this dataset will be served. You need to tell your application to flush the cache every time when certain Model is updated. That way every time you edit, delete or add new Model item, old cache will be flushed, and query will be executed again. Afterwards, resulting new dataset will be cached and served until Model is updated once again. Continue reading Laravel: Model Observers

Laravel: Caching Database Queries

If your application runs a large number of queries very often, with time it will become very, very sluggish. Here Laravel caching comes handy. Laravel provides a simple mechanism for caching these queries using a very simple chained method call. Here is an example using Laravel’s Fluent Query Builder:

Of course, we can do the same thing using Eloquent:

Behind the scene Laravel executes the query and then stores it along with the query result using the cache adapter, with an expiration time of 60 minutes. Running the same query again will result that cached query will be found, which means it will not be executed again, instead the results will be taken from the cache. Continue reading Laravel: Caching Database Queries

Setting Up Laravel Environments

Setting up a development environment is an important task you should do before starting any project. We all know that Laravel has a lot of cool features and one of things I like a lot is how easy is to set environments on your machine. Official documentation page provides you a lot of useful information about it, so make sure you check it.

Typically for each project you would need to have development, staging and production environments. All of these should be on separated servers, so configuring each environment can be a bit tricky.  But not with Laravel. Continue reading Setting Up Laravel Environments