TwigExpress packages the Twig templating engine, and a few other tools, in a single file.
Our goal is to make it easy to get started with Twig if you’re a designer or a front-end developer, without having to install a heavy PHP framework or CMS.
Main features:
- Browse and serve files (⚠ only for development!)
- Render Twig templates
- Error pages with code excerpt, source view
- And a few extra tools for prototyping (dummy text, Markdown to HTML…):
- Running TwigExpress
- Adding content
- Writing Twig templates
↪ Getting Started with Twig
↪ TwigExpress-specific features - Configuration
↪ TwigExpress configuration reference
↪ Using TwigExpress with Apache - Library and license info
PHP 5.4+ available on the command line.
- On macOS, you should have PHP installed already.
- On Windows, one easy way to install PHP (and other tools) is XAMPP.
- Download a ZIP of this repo and unzip.
- Recommended: rename
twig-express-master
to your project’s name.
Open your project folder in a Terminal or Command Prompt and run this command:
php --server localhost:8000 twigexpress.phar
Now load http://localhost:8000/ in a web browser to browse your files.
Any file ending in .twig
will be interpreted as a Twig template. You can check out the example pages in the demo
directory.
After installing TwigExpress, you should have a folder whose content looks like this:
myproject/
demo/
LICENSE
README.md
twigexpress.json
twigexpress.phar
If you don’t care about the demo and read-me, you can keep these only:
myproject/
twigexpress.json
twigexpress.phar
You can add your own content anywhere. This content can be Twig templates (which must have the .twig
extension), CSS, scripts, images, etc.
Example file path | Corresponding URL |
---|---|
myproject/index.twig |
http://localhost:8000/ |
myproject/some/page.twig |
http://localhost:8000/some/page |
myproject/css/styles.css |
http://localhost:8000/css/styles.css |
There are two sets of features available in templates:
-
Syntax and features native to the Twig language
See our short guide “Getting started with Twig”, and the official “Twig for Template Designers” guide. -
Features specific to TwigExpress
We’re added a few extra features to help you write HTML prototypes, such as a dummy text generator and a Markdown parser.
Configuration goes in a twigexpress.json
file at the root of your project. This file should follow the JSON format (here’s a good introduction).
More information:
TwigExpress is licensed under the MIT License.
We are using the following libraries:
- Twig library (BSD License)
- Karwana\Mime (MIT License)
- Parsedown (MIT License)
- php-loremipsum (MIT License)
- highlight.js (BSD License)