Hire developers Community Blog Find a dev job Log in
Close menu
Tech insights: Writing Better Code: Why I'm Excited About Laravel [Q&A]
Less noise, more data. Get the biggest data report on software developer careers in South Africa.

Writing Better Code: Why I'm Excited About Laravel [Q&A]

21 September 2018, by Richard Klugman

Technological decisions don’t just affect the products we build. The unique combination of different frameworks, architectures and languages often also influence our mindset. That’s why we are asking South African software makers about their experience and what they are excited about. This time, Senior Dev Richard Klugman tells us about Laravel.

Inner-cover-image-1

How did you get into Laravel?

A former colleague expressed how robust the framework was a few years back, but I never got around to really trying it. Then a project came along that was built from the ground up with Laravel.

When I saw the flow of the framework and the way it does things, I was instantly hooked:

  • Database integration - Laravel totally codifies your interaction with the database. Most queries can be achieved with framework functions instead of having to write out raw SQL queries.
  • They have come up with an intuitive way of structuring things that makes it easy to navigate new applications. The fact that my current company, for example, is using Laravel, really helped me get up to scratch when I joined only a few months ago. It is a MVC directory layout with other directories dedicated to other application functions such as Listeners, Messaging, Exceptions, Logging.

What are you most excited about and why?

It’s almost like the framework knows what you want to achieve with your application: It’s clear that the creators of Laravel worked on many applications, made sort of a summary of the most common things an application would use and provided out-the-box functionality for them. So when it comes to building an application from scratch, you can get into the uniqueness of your application straight away without having to worry about setting up things like environments and drivers.

It’s a framework made up of mini frameworks. Laravel provides ready to go and easy to configure application components such as authentication, caching, commands, notifications, events, collections and queuing:

Here are some I’ve found most useful:

  • Collections: This is essentially array handling on steroids. Converting an array to a collection provides you with a plethora of framework functions to achieve whatever business operation you want to perform. Yes, all these functions can be achieved using vanilla PHP, but why write code that’s already given to you?
  • Event listeners: These help you write a dedicated piece of code that will be performed when specific application workflow step is reached. This way, when, for example, my entity has reached approval, it can now run specific operations or business logic.
  • Observers: This, while very similar, is more for database workflow steps, such as create, save and delete. It’s the first time that I’ve worked with this concept. The framework picks up which one of the different states of a life cycle the model is in. Laravel then gives you the window to run different operations based on that specific state in real time.
  • Blade: This is Laravel’s encapsulated frontend framework. It integrates seamlessly from backend to frontend and allows you to inject backend PHP data with annotations into the DOM rendering. It’s almost like your backend is talking to your frontend.

In addition to these, Laravel caters for all the most common software vendors one uses which can often save you a few days. As an example, cooking up a MySQL/Postgres database structure is super fast and easy with Laravel.

Another benefit is that it’s updated very often based on the community’s feedback or any new PHP features when a new PHP version is released. This continuously provides me with new functionalities and things to test out.

How does this affect you as a software maker?

Based on the ethos of Laravel, it makes me stop and think about how I can do things better.

1) Can I improve the way I have written a new piece of code?

As I mentioned, one can easily see that Laravel is constantly improving a lot of things within its own framework. You are constantly learning the new things they are adding and this inspires me to approach my own code in the same way. That’s why I asked myself: Can I too, with the tools I have been given, reduce the cognitive load for my peers?

2) Have I architected things logically?

Laravel does things in a way that works so there’s not really any reason to go against this way. For example, there is absolutely no reason to connect to your database in your own way when Laravel is already providing a great solution for that. That why I now always first ask myself: “Can I write this new functionality according to Laravel’s way?”

3) Maybe I should change my approach?

When I started working with Laravel, I started seeing better ways of doing things. A good example for this are collections: The way arrays are handled in the framework has structured my code better and the overall quality of the code has improved as well.

Just because I have always done things in a certain way and which has been acceptable, doesn’t mean I can’t change to something better now.

4) Trust and understanding of framework functionality

Normally, when I don’t use a framework, I would write my own code, test it and then trust that it runs in the way it should. If you use a framework that you believe in, you can delegate that testing to the people who build it. This is something I personally had not experienced before Laravel.

With Laravel, there have been quite a few times when I’ve come across functionality where I really couldn’t figure out how it was done. Now, one could sit and try to see how the framework does it or just regard it as ‘Laravel magic’. The trust of the framework is such that you can safely do the above.

That said, if you do have some spare time to peruse the building blocks of the framework, it is good to see how the framework performs certain tasks. This could help you going forward if you have slightly misunderstood some functions.

How can others learn about/get started with this?

Laravel reference documents are robust and intuitive. There are also Laracasts which are super helpful. There are even Laravel evangelists who published their own content to help the community

  • Official Documentation: Elaborate and easy to understand explanation of functions and concepts

  • Laracasts - New Features and Tutorials. Insightful walkthroughs of new features and tutorials on how to set up the various mini frameworks in Laravel

  • Follow the founder - Taylor gives constant updates on the roadmap for the framework and raises points about the shortcomings of general development vs the Laravel way


Richard is a Senior PHP Developer and a conscientious, inquisitive developer. He wants to always learn new things and get excited about new features.

Source-banner--1--3

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Subscribe to our blog

Don’t miss out on cool content. Every week we add new content to our blog, subscribe now.

By subscribing you consent to receive OfferZen’s newsletter and agree to our Privacy Policy and use of cookies.