Fork me on GitHub

Maxim Lanin

Email templates optimization for Laravel

Posted in Laravel, PHP

Optimize your email templates’ styles via native Laravel templating mechanism.

If you want to send an HTML email you can’t just send it with <style></style> tag in it, or link a stylesheet. Most of the email clients will cut it and clients will see your email without any styles.

The only approach to achieve best email quality is to convert all your styles int inline style="" attributes.

API Exceptions for Laravel

Posted in Laravel, PHP

All in one solution for exception for JSON REST APIs on Laravel and Lumen.


The goal of this package is to provide you with a set of most common exceptions that may be needed while developing JSON REST API. It also:

  • Handles exceptions output.
  • Handles exceptions report to logs.
  • Overwrites default Validator to make validation errors more verbose.
  • Has a FormRequest that to handle validation errors and pass them to ApiExceptions layer.
  • Has middleware to catch all system errors such us RuntimeExceptions or ModelNotFoundException to handle them and threat as normal ApiExceptions.

Load Your JavaScript Library Asynchronously

Posted in JavaScript, HTML5

Lets imagine, we have a common page:

<!DOCTYPE html>
    <script src="app.js"></script>
      App.init('greeting', 'Hello, John Doe!');
    <h1 id="greeting"></h1>

With javascript library included:

// app.js
var App = {
   * Handle already registered actions.
   * @param  {String} id   Element ID
   * @param  {String} name User's name
  init: function (id, name) {

Add handy setup wizard to your Laravel project

Posted in Laravel, PHP

Imagine that you distribute your Laravel project. It is awesome, useful and remarkable. But every time your customer installs it, he has to perform a set of steps to setup it: add .env file, run migrations and seed, etc. And you have to mention them all in your README and hope that user will do everything right. But why not to guide your customer through all this steps with one simple command?

All you have to do is to add Laravel-Setup-Wizard package to your project!


Laravel + Hashids

Posted in Laravel, PHP

Everyone nowadays used youtube or any short link creator. If you look to the links they use (eg. you will notice that they use unique string hashes instead of common auto-increment ids. They do it because anyone can just iterate ids and get access to all their content. And of course they don’t want it.

If you want to protect your content too, you have to replace your ids with hashes. There are lots of tools that can convert integers to unique hash ids. They work practically identically, and I will show how to integrate one of them Hashids with Laravel.

There are lots of packages that already integrate Hashids into Laravel, but they only add it’s facade and give some syntactic sugar. But we need complex integration with easy model binding and all logic under the hood! So let’s do the magic!

Extending default Laravel 5 Router

Posted in Laravel, PHP

While working with Laravel framework sometimes it becomes necessary to extend it’s default Router. It Laravel 4 this process was pretty simple and was described in the official manual. But in Laravel 5 this process became more complicated and has some pitfalls.

Form Request validation errors

Posted in Laravel, PHP

For the last half a year since Laravel 5.0 was released I saw lots of questions on how to handle validation errors using new feature Form Requests. So I decided to cover all options.

Easy debug for your JSON API

Posted in Laravel, PHP

When you are developing JSON API sometimes you need to debug it, but if you will use dd() or var_dump() you will break the output that will affect every client that is working with your API at the moment. Laravel-API-Debugger is made to provide you with all your debug information and doesn’t corrupt the output.

Extend your Laravel Seeder

Posted in Laravel, PHP

Laravel brings you awesome seeding functionality. But it is not as perfect as it could be. By default Laravel Seeder was made to store random data (it even suggests you to use Faker package). But what will you do if you have lots of data that already exists in my DB? There are several ways to achieve this. You can import raw arrays, SQL data, or use CSV files. I choose the third approach because CSV files are easier to edit. That’s why I created a Laravel-Extend-Seeder package that implements this method.