12.1 What Is Server-Side Development?

Chapters 1 and 8 introduced the basic client-server model at the heart of the web. So far, this book has been almost completely focused on the client-side of that model, that is, with the technologies of HTML, CSS, and JavaScript. While contemporary web development is heavily client-side focused, the server-side of the model is still essential.

12.1.1 Front End versus Back End

You may recall that the terms “front end” and “back end” are often used interchangeably with “client-side” and “server-side” when it comes to web development. HTML, CSS, and JavaScript are the technologies of the front-end and are focused on the presentation and control of the web application’s user interface.

What are the technologies of the back end and what are they used for? The answer to these questions has varied over time. Server-side technologies provide access to data sources, handled security, and allowed web sites to interact with external services such as payment systems. Traditionally, most sites made use programs running on the server-side to programmatically generate the HTML sent to the browser. Figure 12.1 illustrates this traditional division between the responsibilities of the front end and the back end.

Figure 12.1 Front-end versus back-end

The image contains 5 steps, 2 browser windows and 1 server window. The image shows Front-end versus back-end.

In contemporary web development, such traditional approaches are still being used, but no longer universally so. With the wide-spread adoption of JavaScript-focused web applications, back ends have become “thinner”. That is, today many web sites are principally front ends; back end processing is used only for implementing the external APIs that provide data to the front end, for handling security, and for interacting with external services that do not have any front-end API.

12.1.2 Common Server-Side Technologies

There are many different server-side technologies. The most common include the following:

Some of these technologies are only used for older legacy applications, while others have only a relatively small market share. Of these technologies, PHP, ASP.NET, Ruby on Rails, and Node.js are the most popular. This chapter will focus on PHP, while the next will examine Node.

Pro Tip

Although PHP is designed for hosting web applications, it can also be used as a scripting language on your system, and called directly from the command line. To interpret a file and echo its output directly to the console, simply type php and the file name to run it.

php example1.php

Running PHP in this way can be useful to developers since it allows one to run code without having to have a configured web server, and allows output to be captured and redirected. Used in combination with crontab (scheduling software), the command line use of PHP can facilitate scheduled tasks ­running on your web applications, for example, sending email each night to ­subscribers.

Since the output is displayed as plain text and not interpreted through a browser, and headers are not sent like in a regular web development environment, we discourage you developing in this manner while you are learning.

Note

The labs for this chapter have been split into two files: Lab12a and Lab12b.