Documentation · Chapter 02

How does
a website work?

Let us start from zero. Before discussing PHPAML, we will simply observe what happens when you open a page in your browser.

No prior technical vocabulary is required. Every new word is explained before it is used.

≈ 55 min

You already know how the story begins.

You open Chrome, Safari, or Firefox. You type an address, such as phpaml.com, then press Enter. A page appears moments later. This chapter explains that journey without assuming you already know how to program.

Two computers talk to each other.

1Your browser asks

“Can you give me the page for book number 12?”

2The server answers

“Yes. Here are the title, author, image, and page layout.”

The browser is the program you use to visit the Web. The server is the computer that runs the PHPAML application and prepares the answer. Even when both run on your own Mac at 127.0.0.1, these roles remain separate.

WORDS TO KNOW

A small dictionary before continuing

Browser
The program that displays websites: Chrome, Safari, or Firefox.
Server
The program or computer that receives a request and prepares an answer.
Application
The collection of files that produces the website's behavior.
Code
Instructions written by a developer to tell the application what to do.

Where do PHP and PHPAML enter the picture?

PHP is the language used to write instructions executed by the server. The browser does not directly read your PHP classes: the server runs PHP, builds an answer, then sends the browser a result it can display.

PHPAML adds organization and tools around PHP. It starts the server with aml serve, recognizes your page addresses, loads the right code, protects common exchanges, and supports several project types. Your logic remains written in PHP.

PHP

The language: variables, conditions, functions, classes, and objects.

PHPAML

The working framework: startup, folders, routes, responses, and development tools.

What does the browser actually receive?

A complete Web page generally uses several file types. PHP prepares dynamic content on the server; the browser then assembles the received elements.

HTML

Structure and content: headings, paragraphs, links, and forms.

CSS

Appearance: colors, spacing, sizes, and layout.

Images and media

Visual or audio files loaded by the page.

JavaScript

Behavior executed in the browser when needed. AML View can generate it without requiring you to write it manually.

BEGINNER QUESTIONS

You may be wondering…

Does my browser run PHP?

No. PHP runs on the server. The browser receives the produced result.

Why does 127.0.0.1 work without the Internet?

This address points to your own computer. Your browser talks to the server started locally by AML.

Must I understand everything immediately?

No. First remember the browser–server conversation. Precise names will come gradually.

The journey in four simple actions.

1Askfor book 12
→
2Directto the right code
→
3Preparethe requested book
→
4Displaythe finished page

In programming, these actions have precise names: request, route, controller, and response. Do not memorize them yet. The next pages introduce them one at a time using the same example.

By the end, you will answer four questions.

  • What happens after typing a Web address?
  • Why does a project contain several folders?
  • Why do we not put all code in one place?
  • Which PHPAML project type should you choose?

YOUR TURN

For a /books/12 page, write down the four stations crossed before the book title appears.

Show a hint

Start with: request → route → …

SUMMARY

What to remember

  • The browser asks for a page.
  • The server prepares and returns that page.
  • A project uses several steps to organize this work.
  • The rest of the chapter explains each step using the same book number 12.