# Introduction

So you want to build the backend for a native and web application. This volume of the book is about how to to that. We'll talk how to quickly and safely setup everything, and delve into the specifics. We assume that you have some familiarity with PHP and know what a web framework is. Perhaps you used one.

We'll explain how to setup a project from scratch. For the code example we use Laravel is the most used PHP framework for web applications. The concepts written in this book apply to any web backend, though. Most frameworks follow the same usual structure, so it's easy to transfer the knowledge independently of the actual tech stack you are using -- and the book tries to detach itself from being a manual for a specific technology.

In general backend code is a bridge so the frontend can fetch data from the database. There's more than just fetching records, of course: backends exist to provide authentication, access control, data validation and data processing. Otherwise we could just connect the frontend to the database directly.

Over the years backend and frontend split up. In the early days of the web, the 1990s, frontend almost didn't exist. All HTML was generated on the server and Javascript was used for cosmetic changes or to provide some interaction on the webpages. It was only with the advent of a practical way for JS to fetch data (XHR, or AJAX as it became better known) that the frontend started to detach from the backend and take an independent form. Eventually the concept of single page application (SPA) came to be: the idea that users run an entire application on their web browsers which fetches data but is entirely responsible for building the interface, as opposed to generating HTML on the server and making a separate, independent request for each URL, which became known as server-side rendering. We'll address the SSR vs SPA debate later.

The idea of this section is to explain how to design, plan, architect and implement the backend of a web application. We'll go through it step by step, from the considerations when you are starting to finer detail such as how to implement authentication. This is meant to be a practical guide, so we'll go through discussions on debugging and deployment as well. If you read this entire thing you should have a pretty good overview of how to write a backend.