← all projects

phar-web

Proof of concept using single file PHP archives to distribute web projects.
repo php php-phar proof-of-concept

How to create a phar archive that's a portable PHP executable that can be served as a website and/or a commandline application.

Requirements

  1. humbug/box. This is used to manage phar file creation. a. If you have phive installed, install box by running phive install.
  2. (optional)Taskfile. This is used as a task runner. Alternatively read the .Taskfile and execute the contents manually, it's bash.

Anatomy

.
├── bootstrap.php
├── build
│   └── index.phar
├── dist
│   └── index-*.zip
└── src
    └── index.php

Building the phar

# Compile in the build/ directory for inspection
t compile

# Compile and run via the commandline:
t crun

# Compile and serve
t cserve

# Create a zip file for distribution
t dist