Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaliop/twig-express
Getting started with Twig templates thanks to a simple PHP script
https://github.com/kaliop/twig-express
html prototyping static-server twig twig-templates
Last synced: 21 days ago
JSON representation
Getting started with Twig templates thanks to a simple PHP script
- Host: GitHub
- URL: https://github.com/kaliop/twig-express
- Owner: kaliop
- License: mit
- Created: 2016-06-22T20:49:52.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-03T18:53:18.000Z (about 6 years ago)
- Last Synced: 2024-03-26T23:34:35.216Z (3 months ago)
- Topics: html, prototyping, static-server, twig, twig-templates
- Language: PHP
- Homepage:
- Size: 1.44 MB
- Stars: 12
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Lists
- awesome-twig - TwigExpress - Getting started with Twig templates thanks to a simple PHP script (Twig / Tools)
- awesome-twig - TwigExpress - Getting started with Twig templates thanks to a simple PHP script (Twig / Tools)
README
TwigExpress
===========TwigExpress packages the [Twig templating engine][TWIG_HOME], 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…):Table of contents
-----------------1. [Running TwigExpress](#running-twigexpress)
2. [Adding content](#adding-content)
3. [Writing Twig templates](#writing-twig-templates)
↪ [Getting Started with Twig][DOC_INTRO]
↪ [TwigExpress-specific features][DOC_EXTRAS]
4. [Configuration](#configuration)
↪ [TwigExpress configuration reference][DOC_CONFIG]
↪ [Using TwigExpress with Apache][DOC_APACHE]
5. [Library and license info](#library-and-license-info)Running TwigExpress
-------------------### Requirements
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](https://www.apachefriends.org/download.html).### Download TwigExpress
- [Download a ZIP of this repo][DOWNLOAD] and unzip.
- Recommended: rename `twig-express-master` to your project’s name.### Usage
Open your project folder in a Terminal or Command Prompt and run this command:
```sh
php --server localhost:8000 twigexpress.phar
```Now load [http://localhost:8000/](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.
Adding content
--------------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
Writing Twig templates
----------------------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”][DOC_INTRO], and the official [“Twig for Template Designers”][TWIG_INTRO] guide.- **Features specific to TwigExpress**
We’re added [a few extra features][DOC_EXTRAS] to help you write HTML prototypes, such as a dummy text generator and a Markdown parser.Configuration
-------------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](https://www.digitalocean.com/community/tutorials/an-introduction-to-json)).
More information:
- [TwigExpress configuration reference][DOC_CONFIG]
- [Using TwigExpress with Apache][DOC_APACHE]Library and license info
------------------------[TwigExpress][] is licensed under the MIT License.
We are using the following libraries:
- [Twig library][TWIG_LIB] (BSD License)
- [Karwana\Mime][MIME_LIB] (MIT License)
- [Parsedown][] (MIT License)
- [php-loremipsum][] (MIT License)
- [highlight.js][] (BSD License)[TwigExpress]: https://github.com/kaliop/twig-express
[DOWNLOAD]: https://github.com/kaliop/twig-express/archive/master.zip
[DOC_INTRO]: https://github.com/kaliop/twig-express/blob/master/doc/intro.md
[DOC_EXTRAS]: https://github.com/kaliop/twig-express/blob/master/doc/extras.md
[DOC_CONFIG]: https://github.com/kaliop/twig-express/blob/master/doc/config.md
[DOC_APACHE]: https://github.com/kaliop/twig-express/blob/master/doc/apache.md[TWIG_HOME]: https://twig.sensiolabs.org/
[TWIG_LIB]: https://github.com/twigphp/Twig
[MIME_LIB]: https://github.com/karwana/php-mime
[TWIG_INTRO]: https://twig.sensiolabs.org/doc/1.x/templates.html
[Parsedown]: http://parsedown.org/
[php-loremipsum]: https://github.com/joshtronic/php-loremipsum/
[highlight.js]: https://github.com/isagalaev/highlight.js