[WIP] Templating in PHP
An example to go along with a guest lecture at Madison Area Technical College's Advanced PHP class.
Comparing standard PHP templating practices to Twig.
- Make sure composer is installed globally or for this project.
composer installto install dependencies.
- In terminal run
php -S localhost:8080to create a local PHP server (or whatever port you like).
- The home page will give you the twig version and this will give you the vanilla PHP version (which currently simulates a scripting "attack"
The Point of This Execise
To show folks some of the differences and baked-in goodies one gets when using something like twig for templating.
This is using the standard "todo app" concept as a starting point.
Maybe some Resources 🤷:
Additions for the [WIP]
- Add in a couple other templating options (e.g. blade, handlebars, etc.) to explore the similarities and differences.
- Hook templates up to an API, database, or todo app to show how to work with an API or database.