php-lab

php-lab: four PHP projects, from plain PDO to Drupal

A monorepo of small, focused exercises built around one theme: a fictional town hall (Comune di Esempio) and its public notices (avvisi). Each project shows the same ideas at a different level of abstraction, with tests, static analysis and CI.

pdo-crud

Plain PHP 8 contacts CRUD: PDO, PSR-4, enums, CSRF/XSS protection, PHPUnit.

laravel

Notices board: routes, Eloquent, Form Requests, Blade components, feature tests.

drupal10

Municipal site with Bootstrap Italia: content types, Views, custom module and theme.

wordpress

Child theme and plugin: custom post type, taxonomy, meta box, REST field, Elementor widget.

pdo-crud

A contacts manager written without a framework, to show the building blocks that frameworks are made of.

Highlights

  • Front controller in public/index.php: the only file the web server exposes.
  • readonly value object, backed enum with match, constructor promotion, named arguments.
  • Repository interface with a PDO implementation using prepared statements only.
  • CSRF token checked with hash_equals; every value escaped on output.
  • Domain exceptions mapped to 404 / 422 responses.

Tested with

  • Unit and integration tests (SQLite in memory).
  • PHPStan level 8 and PHP_CodeSniffer in GitHub Actions.

Read the code →

Contacts list with search and category filter
Contacts list
Form showing validation errors
Server-side validation

laravel

A quick but complete tour of Laravel: a notices board for the town hall with CRUD, filters, validation and tests.

Highlights

  • Route::resource with a 7-action controller and route model binding by slug.
  • Form Request validation with Rule::enum; one enum shared by model, validation and views.
  • Model casts, scopes and model events; migrations, factories and seeders.
  • Blade layout and reusable components, Bootstrap 5 without a Node build.

Tested with

  • Feature tests with RefreshDatabase.
  • Compare with the plain PHP version to see what the framework does for you.

Read the code →

Notices list with category filter
Notices list
Single notice page
Notice detail
Form with validation messages
Form Request validation

drupal10

A municipal website built like the Designers Italia "modello Comuni", with a custom module and a Bootstrap Italia theme.

Highlights

  • Content type avviso with a taxonomy reference (road works, events, services, emergencies).
  • View /avvisi with cards, exposed category filter and pager.
  • Custom module: routing, controller, services with dependency injection, config form, block plugin.
  • Custom Twig theme on Bootstrap Italia (installed with npm, no CDN); cache tags on render arrays.
  • Configuration management in git, plus notes on the 9 → 10 upgrade and WCAG 2.1 AA.

More docs

Read the code →

Town hall home page with highlighted notices
Home page
Avvisi list built with Views
Avvisi (View with filter)
Single notice page
Single notice
Summary page from the custom module
Custom module page
Module configuration form
Config form

wordpress

Extending WordPress without touching core: a child theme and a notices plugin for the same town hall.

Highlights

  • Child theme of Twenty Twenty-One: actions, filters and the template hierarchy.
  • Plugin comune-avvisi: custom post type, taxonomy and a meta box.
  • Secure form handling: nonces, capability checks, sanitising and escaping.
  • Shortcode, REST meta field and a custom Elementor widget.

More docs

Read the code →

WordPress home page with latest notices
Home page
Notices archive
Notices archive
Single notice
Single notice
WordPress admin list of notices
Admin screen
Why screenshots and not live demos? This page is a static site on Cloudflare Pages, which does not run PHP. To click through the real apps, open the repository in GitHub Codespaces: a setup script builds all four sites on SQLite with demo content. Notes: PHP interview cheat sheet · How it was built and tested (Chinese with Italian answers).