Cairn is a Bash script built for anyone who uses PHP to template their web projects. We here at LugoCorp use simple PHP templating on a variety of sites, so we created this simple build tool to help automate our rollout process. Cairn is a single command that builds every index.php file into a build folder, at the same time copying over all of your non-PHP media files. We use it to maintain the LugoCorp website itself as well as a variety of client sites.


Cairn is a very simple command line build tool. Its usage is defined here:

Usage: cairn <src> <dst>
  src - the project directory to be built
  dst - the build destination

You can also install Cairn from your command line like so:

curl https://raw.githubusercontent.com/alugocp/cairn/main/cairn.sh > cairn.sh
mv cairn.sh /usr/bin/cairn

Remember always be careful when running a command you found online! You don't have to run the above code to install Cairn, you could also clone it from GitHub and then optionally copy it to where you keep your executable files.

Project Layout

Cairn works by reading every file in the provided source directory. It runs every index.php file it finds through your PHP interpreter, producing an index.html in the destination folder. This way Cairn can handle subroutes in your web project, assuming each one contains an index.php. It also copies over all non-PHP files to the build folder, preserving your original code's structure and layout.

The end result is a mirror image of your PHP project, but every route has been built into static HTML. From here you can upload it to GitHub pages (or wherever you host it) and deploy! Cairn handles the build process of your PHP template sites, freeing you up to focus on their design and development.

Who Uses Cairn?