|
| 1 | +# LeFuel Architecture |
| 2 | + |
| 3 | +LeFuel is a fork of FuelPHP 1.8 targeting PHP 8.1+. This document describes every top-level folder and its purpose. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Root |
| 8 | + |
| 9 | +| Path | Purpose | |
| 10 | +|------|---------| |
| 11 | +| `composer.json` | Dependency manifest. Packages install into `fuel/vendor/` (third-party) and `fuel/core/`, `fuel/packages/*/` (FuelPHP packages). | |
| 12 | +| `oil` | CLI entry-point. `php oil <command>` runs generators, migrations, tasks, and the built-in test runner. | |
| 13 | +| `Dockerfile` | Single-stage `php:8.3-cli` image that serves the app on port 8000. | |
| 14 | +| `docker-compose.yml` | Defines the `app` service (this image) and a `mysql:8.0` service with a persistent named volume. | |
| 15 | +| `.env.example` | Template for the `.env` file that each environment copies and fills in. Never committed. | |
| 16 | +| `.github/workflows/ci.yml` | GitHub Actions matrix CI — runs PHPUnit against PHP 8.1, 8.2, and 8.3 with a MySQL 8 sidecar. | |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## `fuel/` |
| 21 | + |
| 22 | +The entire PHP runtime lives here. Only `fuel/app/` is committed; everything else is Composer-installed and git-ignored. |
| 23 | + |
| 24 | +### `fuel/app/` |
| 25 | + |
| 26 | +Application code you write and own. |
| 27 | + |
| 28 | +| Sub-path | Purpose | |
| 29 | +|----------|---------| |
| 30 | +| `bootstrap.php` | Application bootstrap. Loaded by `public/index.php`; sets the app path and environment, then hands off to the FuelPHP kernel. | |
| 31 | +| `classes/controller/` | HTTP controllers. Each file is a class named `Controller_<Name>` extending `Controller` (or a sub-type). Methods prefixed `action_` map to URL segments. | |
| 32 | +| `classes/model/` | Data-layer models. Extend `\Orm\Model` for Active Record, or use raw `DB::` calls. | |
| 33 | +| `classes/presenter/` | Presenter/ViewModel layer. Sits between controllers and views, keeps logic out of templates. | |
| 34 | +| `config/` | Configuration files. `config.php` is the master config; `db.php` holds database DSNs. Sub-folders (`development/`, `production/`, `staging/`, `test/`) override settings per `FUEL_ENV`. `routes.php` maps URL patterns to controller/action pairs. | |
| 35 | +| `lang/` | i18n strings, keyed by locale (`en/`, etc.). | |
| 36 | +| `logs/` | Runtime log files (git-ignored below day level). | |
| 37 | +| `cache/` | File-based cache output (git-ignored). | |
| 38 | +| `migrations/` | Numbered migration files run via `php oil r migrate`. | |
| 39 | +| `modules/` | Self-contained feature modules. Each module mirrors the `app/` structure and is loaded on demand. | |
| 40 | +| `tasks/` | CLI task classes run via `php oil r <task>`. `robots.php` is the bundled example. | |
| 41 | +| `tests/` | PHPUnit test suites mirroring `classes/` (controller, model, presenter, view sub-directories). | |
| 42 | +| `themes/` | Theme asset sets for the Theme package (optional). | |
| 43 | +| `tmp/` | Transient working files (e.g. upload staging). Git-ignored. | |
| 44 | +| `vendor/` | App-level Composer packages (distinct from `fuel/vendor/`). Rarely used directly. | |
| 45 | +| `views/` | PHP view templates. Organised as `views/<controller>/<action>.php`. | |
| 46 | + |
| 47 | +### `fuel/core/` *(git-ignored, Composer-installed)* |
| 48 | + |
| 49 | +The FuelPHP kernel: autoloader, base classes, Input, Output, Request, Response, Session, Security, and all core helpers. Installed to `fuel/core/` via the `composer/installers` path rule. |
| 50 | + |
| 51 | +### `fuel/packages/` *(git-ignored, Composer-installed)* |
| 52 | + |
| 53 | +Optional first-party packages installed alongside core: |
| 54 | + |
| 55 | +| Package | Purpose | |
| 56 | +|---------|---------| |
| 57 | +| `auth/` | Authentication (login, ACL, hashing). | |
| 58 | +| `email/` | Email sending abstraction. | |
| 59 | +| `oil/` | CLI tool internals (generators, scaffolding). | |
| 60 | +| `orm/` | Object-Relational Mapper (Active Record pattern). | |
| 61 | +| `parser/` | Template engine bridge (Twig, Smarty, Mustache, etc.). | |
| 62 | + |
| 63 | +### `fuel/vendor/` *(git-ignored, Composer-installed)* |
| 64 | + |
| 65 | +All Composer third-party dependencies (e.g. `phpunit/phpunit`, `fuelphp/upload`). Managed entirely by Composer; never edit manually. |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## `public/` |
| 70 | + |
| 71 | +The web root. Point your web server's `document_root` here. |
| 72 | + |
| 73 | +| Sub-path | Purpose | |
| 74 | +|----------|---------| |
| 75 | +| `index.php` | Front controller. Sets `DOCROOT`, loads `fuel/app/bootstrap.php`, and dispatches the request. | |
| 76 | +| `.htaccess` | Apache rewrite rules that funnel all requests to `index.php`. | |
| 77 | +| `web.config` | IIS equivalent of `.htaccess`. | |
| 78 | +| `assets/` | Static assets served directly: Bootstrap CSS/JS and Glyphicon fonts. Organised as `assets/{css,js,fonts,img}/`. | |
| 79 | +| `favicon.ico` | Default favicon. | |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Request Lifecycle (summary) |
| 84 | + |
| 85 | +``` |
| 86 | +Browser → public/index.php |
| 87 | + → fuel/app/bootstrap.php (env, paths) |
| 88 | + → fuel/core (Request/Router) |
| 89 | + → fuel/app/config/routes.php |
| 90 | + → Controller_<Name>::action_<name>() |
| 91 | + → View::forge('folder/template') |
| 92 | + → Response → Browser |
| 93 | +``` |
0 commit comments