Documentation · Chapter 02

One platform,
four structures.

PHPAML keeps useful principles, then removes folders with no role in the selected project type.

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

Choose based on the expected output.

Do not choose a variant because it sounds more modern. First ask: who will use the program, and what response should they receive? An HTML page, reactive interface, JSON data, or terminal text naturally lead to four different structures.

They are not four different languages.

In all four cases, you write PHP. What changes is how the program is used. A visitor may receive a complete page, interact with a reactive interface, another application may request data, or a person may run a terminal command.

Classic application

It receives an HTTP request, uses routes and controllers, then generally renders a PHP view on the server.

phpaml — zsh
src/controllers/
src/models/
src/middleware/
src/routes/WebApp.php
src/views/
public/index.php

AML View

It keeps the PHPAML server, while declarative pages and components live under src/views. Engine then handles compiled frontend interactions.

phpaml — zsh
src/views/pages/
src/views/components/
src/views/layouts/
src/views/stylesheets/
src/routes/WebApp.php

API

It uses HTTP, routes, controllers, and data, but has no view layer. Its final representation is generally JSON.

phpaml — zsh
src/controllers/
src/requests/
src/resources/
src/repositories/
src/routes/
public/index.php

Console

It has no browser, HTTP request, or route. Program::main() receives terminal arguments and returns an exit code.

phpaml — zsh
src/Program.php
src/
tests/
phpaml.json

The same catalog, four uses.

Server-rendered library websiteaml create
Reactive search without manual reloadaml create-view
Catalog consumed by a mobile appaml create-api
Import 500 books from a fileaml create-console

Quick comparison.

ProjectUsed fromMain resultIdeal for
ClassicBrowserHTMLServer-rendered websites and forms
ViewBrowserReactive interfaceDashboards and interactive applications
APIMobile, website, or serviceJSONSharing data between applications
ConsoleTerminalText and exit codeAutomation, learning, and scheduled tasks

CHECK YOUR UNDERSTANDING

Must an API have a view?

Show the answer

No. Its final representation is generally JSON. It keeps routes, controllers, and data, but does not need an HTML layer.

YOUR TURN

Choose a variant for: an interactive dashboard, a nightly backup command, a mobile service, and a small institutional website.

Show a hint

View, Console, API, then Classic.

BEGINNER QUESTIONS

You may be wondering…

Can I add Data to these projects?

Yes. The Data module can be added when a project must store and retrieve information.

Does a View application still have a server?

Yes. PHPAML and Engine work together to produce the interface and its interactions.

Can I start simple and add modules later?

Yes. The initial type provides a suitable structure; required modules can then be installed.

SUMMARY

What to remember

  • Classic renders pages on the server.
  • View adds a declarative reactive interface.
  • API responds without views, generally as JSON.
  • Console runs PHP without an HTTP server.