Laravel: The Framework that is the Pillar of our Software

Software developers may all offer the same or very similar services to their customers, but what goes on behind the scenes can be very different. Development companies have their own set of standards, procedures, and policies to follow, and one decision they must make as a company is what language and framework they develop in, which isn't often disclosed to their customers as it's assumed to be unnecessary for them to know.

At CodeBased, we believe that transparency is crucial so have written this blog post to explain what a framework is, and why we have chosen to specialise in Laravel as our main framework.

Introduction to frameworks

All software, in all of its many varieties and purposes, is simply the execution of a list of instructions that the computer can perform: an algorithm. Each instruction given to the machine must be written in such a simplified way that the computer can understand what it must do; the computer doesn't know what the cursor is, or what happens when the mouse is clicked, or what the screen even looks like.

So, for very simple features that we take for granted nowadays, a tiresome, long program would need to be written to perform seemingly simple actions. But writing the same algorithm every time we wanted to create a new feature on a new application would take days to complete. How do we solve this problem?

Introducing frameworks. When the same code is used throughout a system time and time again, we can call upon a framework to scaffold most of the functionality for an application, such as: connecting to a database to store and retrieve data, allowing the user to login and manage authentication within the system, or protecting a user from malicious attacks from third party applications.

Frameworks do a lot of the heavy lifting when it comes to programming which can decrease the time taken for development, keep the software optimised to ensure that the application runs smoothly and efficiently, and can be used to keep applications up to date with the latest technology and the latest trends. This makes it the perfect tool for developing bespoke applications to suit a wide variety of needs.

How and why we use Laravel

Laravel is a framework that is built off of the PHP programming language, this is the perfect language to handle back-end interactions, such as viewing a website, uploading data to a server, and passing data back to the user. It uses the MVC (Model, View, Controller) architecture wherein; the Model stores all of the back-end functionality around a certain entity within the system (say, a user); the View is what is displayed to the user through a markup language, what is used to write text to a screen; and the Controller is used to pass data to and from the View and Model. This architecture is very easy to understand as we can apply an abstract, digital concept to the real world by separating each entity into its own Model.

To store this data, our servers use an SQL database: a series of tables that hold the data that the application uses. When you create a user on an application, the user's email address and password are stored within this database, but before this can happen, we need to create a connection to the database, tell the code to create the users table, and then implement the functionality to input the email address and password into the database, as well as encrypting this information.

Laravel offers the tools to create a wide range of different architectures, with the use of migrations we can create new tables very easily and set up relationships between tables so that they can communicate to each other to improve the performance of the application. Laravel has the capability to create and handle uncommon data structures with ease, allowing for more situational use cases while also making it trivial for simpler structures as every Laravel projects writes a migration for a users table upon creation, including first name, last name, email address and an encrypted password.

In order to navigate around a website, you must enter the correct URL into the web address bar of the browser, which will perform a 'get' request, which will try to access the data that is being stored on that URL in the server. To code this for every URL the application's routing system may take days to complete, but Laravel's Routing structure reduces this time to just seconds per route while keeping the codebase in a tidy and well-structured state.

When inputting data into a form in a web application, we can pass this data up to a Controller through a route, and thanks to Laravel's MVC architecture, it is easy to handle this data and control what happens when the user submits the form. We can also add custom validation into a form, for example, ensuring that a user's password contains certain characters and is of a minimum length, all the while adding customised error messages to display to the user to make sure the user experience is to a high standard, and that any errors are caught and displayed to the user in a clear and concise manner.

To fetch data from the database, Laravel uses Eloquent's Query Builder to make it developer-friendly to write and read complicated SQL queries, by using language that is akin to standard English, and by giving much more complicated SQL queries a single function to call. This helps reduce the number of errors to be made and can quicken the time taken to write complex queries.

Because of the way Laravel is structured, there is a lot of variety in which it can be applied, and for most software we create for our clients, they often request a web application to be used mainly by administrators, and a mobile application to be used by other users such as customers or staff. We can easily create an API in Laravel so that a mobile application can make requests to that API, which will handle all of the back-end data including authorisation, since we can pass data through a Resource which converts the data into something more friendly for use on a mobile device.

The capabilities of Laravel, and its packages

Along with the storing and retrieving of data, Laravel offers a wide array of different features that can be implemented into every application, such as automated tests, security measures and integration with third party applications.

We can write tests using the Laravel integration of PHP Unit, a testing suite which allows us to run tests throughout development as well as when we deploy to an environment. We can write these tests to different scopes, for example, unit tests target a specific functionality such as a user being to view a page, or an unauthorised user getting an error on accessing sensitive data. These tests are written - much like most things in Laravel - to be close to standard English, which makes them easy to understand for a developer.

Writing these tests are important so that any changes we make to our software doesn’t affect the core functionality, and this is shown by running the test environment. Laravel also has packages to aid in testing, such as Laravel Dusk, which allows for testing on a certain environment, and allows for browser testing such as detecting mouse clicks, entering information within an input field, keyboard presses, waiting for components to render to the screen etc. This wide range of tests can make an application unbreakable.

Security is one of the most important aspects of any software, particularly with CRMs and data management systems, and many of Laravel’s features come with built in security as standard, many of the methods used will throw an error whenever the application’s security policies are breached, such as submitting a form without a CSRF verification token.

Along with this, there are many ways for us, as developers, to implement security through reliable and easy-to-implement functions: we encrypt all of the passwords stored in the database, and also deny unauthorised access to the database by checking against code and SQL injections. As well as this, packages such as Spatie Permissions can be used to create roles and permissions for users to restrict a user’s access throughout the system, which is very easy for developers to make changes to, add additional roles and permissions.

When developing web applications, Laravel Blade grants a lot of versatility that would otherwise be absent in core HTML, although one downside to Blade is that it isn’t very interactive without the use of JavaScript, a powerful language that can add feedback to button presses, allow for changing the current state of the application without needing a full page refresh, and adding the ability to add modals and drop-down menus with a great deal of customisation.

Because of this, many developers implement the TALL stack, that is, Tailwind, Alpine, Laravel and Livewire. This combination of frameworks has great potential to make user-friendly, interactive applications with all of the power back-end benefits of Laravel. Tailwind, the CSS framework, makes componentising a website’s front-end styles feel natural, and can make it much quicker to implement new views to an app. Alpine can apply JavaScript’s power into Blade components, and is designed for use with Blade to allow for opening models, adding feedback to user interactions, or conditionally displaying certain aspects of the application. Livewire is designed with both Laravel’s MVC model, as well as Blade components in mind, which calls from the ability of both to be able to produce a greater user experience through responsive and dynamic tables, forms, collapsable menus, modals, etc.

Laravel has a great community surrounding it, with thousands of packages created to help developers make each application unique, and to enhance the ability of developers by increasing development speed, reducing testing time, granting environmental management, or adding functionality that would take too long to implement for a single application.

Other frameworks out there

While Laravel is great for its use in web applications, we utilise many more frameworks depending on the type of software our clients are looking for. One of the most common frameworks we work with is React Native, a JavaScript framework that is used in mobile development that can be deployed to all Android and iOS devices. React Native offers a large amount of functionality, while being written in a style similar to HTML which makes it feel natural as developers to structure, all with reusable and efficient components.

Symfony is another PHP framework that is used to create components for an application quickly, with more versatility than Laravel, and slightly better performance when compared with larger software. However, Symfony doesn’t offer much out-of-the-box functionality when compared to Laravel, including security and validation checks, most of the features included with Laravel are not found in Symfony which means that, as developers, we would either need to write the code for these ourselves or use a dependency which can be problematic for maintainability and keeping the codebase up to date, especially since Symfony’s community is not as widespread as Laravel’s. That’s not to say Symfony doesn’t have its place, as it is a much more efficient framework to use, it will take up less space than the same application written with Laravel, and can be tuned to run on more specialised devices.

As well as Alpine and Livewire, we will often reach for using a framework written for JavaScript in our applications as they can provide better performance and be more optimised to larger applications, such as single page applications (SPAs). We have used JQuery in the past to handle the communication between the front-end and back-end, which is very easy to use to implement asynchronous requests within a Blade or HTML view, which will allow multiple requests to be made at the same time without the user experience suffering from it.

More commonly, we will opt for React for our interactive user interfaces: similar to React Native, React is a powerful JavaScript framework that is written very similarly to HTML, making it more maintainable for developers. This also has all the benefits of React Native, such as an effective way to control the state of the application, and creating smooth, interactive components to maximise the user experience.

Conclusion

It’s important to understand the pros and cons of a company’s chosen framework so that, as a customer, you are able to make a more informed decision about which company you would like to engage with. Also, raising questions to a software developer can give you knowledge of the inner workings of the development process, while giving a more stable medium for customers and developers to communicate between. Here are some questions around frameworks that you might want to ask your software development team to see if the framework suits your expectations, or to gain some insight into why your development team has chosen a certain framework:

  • What programming language and framework do you recommend for my project, and why?

    This question is fundamental as it provides insight into the software company's expertise and reasoning behind their technology choice, directly impacting your project's success.

  • Can you provide examples of similar projects you've completed using this language/framework?

    Evidence of past success with similar projects is a strong indicator of a company's ability to deliver on your project.

  • What are the pros and cons of using this language/framework for my project?

    Understanding the advantages and limitations helps you gauge potential challenges and the software company's transparency and honesty.

  • How does the chosen technology stack impact deployment and hosting options?

    Deployment and hosting are crucial for the practical day-to-day running of your application, affecting performance, scalability, and costs.

  • What is the expected maintenance and scalability of the application with this language/framework?

    Long-term considerations are essential. This question addresses how the application will grow with your business and what ongoing support you might need.

Focusing on these questions will help to understand the technical alignment, experience and approach of each software company, which will help you towards making a well-informed decision.