compile twig.phar
It is very popular to use Twig on developing with PHP. But it is not easy to deploy my application with Twig because there are a lot of files to deploy. I want to deploy it easily.
So I tried to make twig.phar, which is PHP Archive.
The phar extension provides a way to put entire PHP applications into a single file called a "phar" (PHP Archive) for easy distribution and installation.
It is similar to "jar" (JAVA Archive) in Java.
via: about phar in PHP documentation
This article is a memo for PHP developers who are like me.
compile.php
As first, let's get Twig sources from git.
$ git clone https://github.com/fabpot/Twig.git
It is "compiler.php", which compile twig.phar file.
If it occurs error when you run this script, you have to set "phar.readonly" to "Off" in php.ini.
Sample code with twig.phar
Then, you have only to call with "phar://" like below:
As the result, you have only to deal with this twig.phar file. It is very simple.