Category Archives

9 Articles


9 Laravel Experts Share Most Annoying Development Mistakes

Posted on
9 Laravel Experts Share Most Annoying Development Mistakes

Laravel is the most starred PHP Framework on Github, powering over 37,794 websites on the internet. Sadly, a good number of these websites were built by half baked developers  – owning to ease of use of the Laravel framework.

The best programmers are up to 28 times better than the worst programmers. – Robert. L. Glass

Having gone through several projects on github, following the core principles of Laravel development in every project possible, one can easily differentiate a great developer from the regular guy; those who write spaghetti code from the really good guys. For some developers, it’s about getting the project done as quick as possible, while for others, it’s usually trial-and-error which in most cases, leads to mistakes that becomes an integral part of the project.

To understand these mistakes, we reached out to prominent Laravel experts across the world such as Graham Campbell, Prosper Otemuyiwa, Dries Vints, Mark TopperVincent TalbotJacob Bennett, James Brooks, Ajeh Emeke, and Alex Bowers – with the question “What ONE Laravel development mistake drives you crazy?”. Drawing on the experience and skills of these experts, we present you 8 Laravel mistakes that annoy most experts.

Bad code coupling to the Config method.

Graham Campbell – Laravel Contributor, StyleCI, Student (My views are my own, and are not that of Taylor Otwell, Laravel, or Alt Three Services Limited)

I see this all the time in laravel packages. They randomly call the global config function, without knowing if it even exists, or caring about the code coupling. The ONLY way you can call “config” is if you’ve actually got laravel/framework as a dependency.

The use of Fat Models & Controllers.

Prosper Otemuyiwa – Technical Writer, Auth0 Inc 

Abstraction is key. Tons of business logic should be moved to service classes rather than piling them up in your models and controllers.



Dries Vints – Lead Developer, BeatSwitch

Keep Eloquent/ORM logic inside models/services instead of controllers.

 Writing program logic in blades



Ajeh Emeke – Software developer at Codulab

Doing this:

@if(Auth::user()->role == 'admin')

which could have just been embedded inside a model as a custom method to become this:


I try to make sure every logic stays in the controllers. For the later, it’s a lot easier to change the admin detection criteria across the application by simply tweaking the isAdmin method in the model rather than looking for every occurrence of ‘admin’.

Inadequate unit testing

Mark Topper – Creator of Ulties Solutions

The one thing that makes me most crazy is the amount of Laravel based projects out there WITHOUT any form for unit testing to ensure it is working. Laravel comes with a simple solution for building small but yet powerful tests without much knowledge of the PHPUnit system; with just the basic Laravel understanding anyone should be able to make unit tests for their Laravel projects. Sadly what makes me crazy, is that it is not always done! 

Unnecessarily formatting database Fields

Vincent Talbot – Senior Web Developer, Libéo

Trying to re-implement the magic of Laravel because they don’t believe in it (Getter/Setter for each properties in the models).

Failure to validate user input

Jacob Bennett – Co-host of the North Meets South Web Podcast and Laravel News Podcast

Failing to validate user input is a big one. Many new developers assume that the values in their front-end forms are the only values that could be sent through to their application. Thankfully Laravel makes this laughably easy these days thanks to FormRequests and the use of `$this->validate()` in your controllers.”

Improper implementation of queue jobs scheduling

Alex Bowers – Software Engineer at Shopblocks

 The use of scheduling in a clustered setup often leads to duplicated jobs. Most developers do not have a clustered development environment and so do not notice or expect this. It is trivial to counteract.
Make use of your cache to store a mutex on each of the scheduled tasks. This way you can guarantee that the job will only be queued once, regardless of how many servers your application utilizes.

Not reading the source code

James Brooks – Lead Developer, Blue Bay Travel

Not reading the source code! You’ll find so many interesting snippets in there.


We went to great lengths to identify and reach out to these elite programmers so we could gather what actually bugs people on a daily basis. Sadly, some of the above mistakes appears to be painstakingly obvious; the question is why do developers still make them? A simple answer perhaps, can be that they became too integrated with these practices hence, not willing to unlearn. Not too good.

Don’t ever get used to bad practices. Do your best to deliver and demand the best development practices possible. Do it for yourself and for others who might work on the projects in the future.


What career or freelance opportunities are there in Laravel besides development?

Posted on
What career or freelance opportunities are there in Laravel besides development?

Laravel is undoubtedly the most popular and widely used PHP framework by experienced software engineers across the world. One major reason is the fact that it offer developers the luxury of building robust applications with ease. As a developer, more often than not, all you need is an idea or a client’s project and you’re ready to put your Laravel skill to work. However, it’s not every time one gets interesting projects to work on. But of course, one has to keep making money.

What’s next? If you’re looking for other ways to put your Laravel skills to good use, these 5 tips will help you boost your portfolio, effectively break into the tech scene, while you make more money.

  • Offer paid laravel tutorials: It’s true there are several Laravel tutorials already, but not everyone wants to build the same thing. Offer exclusive tutorials to teach people how to build particular project of their choice.
  • Laravel Hosting service: With the numerous tutorials on hosting laravel projects, most developers still find this a very difficult task. Offer to help and get paid in return. You could even start your own hosting site exclusively for Laravel projects.
  • Be a Laravel mentor: A good place to start mentoring other developers is the code mentor website.
  • Offering security services: Security is a VERY important feature for any web applications.

I hope this article has been with helpful. Be open-minded, try new things and the sky is your starting point!



Restricted; A package that restricts usage of protected username

Posted on
Restricted; A package that restricts usage of protected username

Most of the time people want a username which is personal, and means something to them.

As developer, an admin or manager of any website, you would agree that sometimes, it’s important to be able to reserve certain names that you consider official. A good use case here is Twitter. No account names can contain Twitter or Admin unless they are official Twitter accounts.

Imagine you’re building an application that requires a dedicated URL like, but then, a user signups with a username ‘tailor’. This would result in conflict as the system could malfunction trying to determine which URL request to respond to. It becomes even more complicated when a user signs up on your application using words such as; Admin, User, Reset, etc as their usernames while creating a profile on your application.

Why don’t we secure these important words by preventing it users from being able to use them in the first place? In response to this, we created a package – Laravel Restricted which tells the application to index all the application’s route segments and restrict users from choosing them as a username.

How to setup

Install via composer
composer require codulab/restricted

Add the following service provider to the array in: config/app.php


Publish the config

php artisan vendor:publish --tag=restricted_config

Now, you can simply add ‘restricted’ to your validations in the controller like so:

$this->validate($request, [
'name' => 'required|string|min:5',
'username' => 'required|restricted' // You’re restricting the username field.

You can also add a new validation message:

To view all the words you have ‘Restricted’, navigate to ‘public/restricted-usernames.txt’ file.

You should see this:

Now when you try to use one of the ‘Restricted’ usernames, you should see something similar to this:

    As far as your application requires a registration process, this package is a simple security measure to protect your website.

If you like Laravel Restricted, please STAR it, SHARE it with your friends, USE it and CONTRIBUTE to it.


Setting up Laravel 5.1 on a Shared Hosting Server

Posted on
Setting up Laravel 5.1 on a Shared Hosting Server

In the course of building products. You will encounter a situation where some of your users are hosting your product on a shared server. So here is how to do it if you encounter such problem.

First, let say in your shared hosting, you have current www or public_html directory, which is accessible publicly via web domain

Let say your laravel project is named laravel50 with the following folder structure:

After you have copied all the files to your www or public_html folder of your shared hosting. Create a folder and name it protected. You can call it any other name that you like. Then move all the files and folders to this new folder you created except the public folder. So you new folder structure would be

|--protected |--app

Then after that, move all the content in the public folder into the main www or public_html folder. Your final folder structure would then be like this

|--protected bind('path.public', function() {
return __DIR__;

$kernel = $app->make('Illuminate\Contracts\Http\Kernel');

$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()


$kernel->terminate($request, $response);

After that open server.php in the protected folder and line 21 to something like this


$uri = urldecode(

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'../'.$uri))
return false;

require_once __DIR__.'../index.php';

And that’s it.

I would also recommend using the same folder structure during your development so that you can experience the whole process of deployment before you upload to your hosting server.

Hope this helps!


Dynamically output Javascript/CSS with a Laravel Route and Controller

Posted on
Dynamically output Javascript/CSS with a Laravel Route and Controller

I was working on an application and I needed to output a dynamic javascript file for inclusion from external websites with the [script src=””] tag. Also I needed to pass some variables to the view which is using the Blade engine.

For a quick solution to serving up a Javascript or CSS file using Laravel routes, i.e., take a look at the following snippet.

public function serve_js()
$contents = View::make('javascript.client-js', [ 'data' => $data //If you are passing extra data ]);
$response = Response::make($contents, 200);
$response->header('Content-Type', 'application/javascript');
return $response;

A file exists in app/views/javascript/ folder named client-js.blade.php. This file only contains the javascript needed to be served. E.g

width: 500,
height: 300,
autoSize: true,
autoHide: false,
time: 3000,
effect: 'fall',
type: 'correct',
title: '',
hasClose: true,
content: '{{ $content }}' });

This code can be adapted to serve CSS as well, just change Content-Type to be text/css.