A ridiculously simple mini web tool to generate C++ boilerplate files the way I like
PHP Makefile Smarty Shell Ruby
Latest commit 30a022a Jul 8, 2015 @rpavlik Update README.mkd
Change my email, link to the powershell scripts.
Failed to load latest commit information.
Makefile Check test-locally as well with phplint Jul 7, 2015
README.mkd Update README.mkd Jul 8, 2015
dotest.sh Add some tests. Jul 7, 2015
family.php Add a c-safe header "ch" Jul 7, 2015
favicon.ico re-generate the icons. Jul 7, 2015
generate.php Fix file modes. Jul 7, 2015


Generate C++ Boilerplate

I turned the shell scripts I habitually use to create new C++ files into a simple little PHP web app so my colleagues that aren't always in Linux can start the good habit too.

generate-cpp-boilerplate homepage on GitHub

Related: A PowerShell script (and another script that installs it) for making send-to menu items to generate files using this web app: Boilerplate Send-To

Original author: Ryan Pavlik, ryan.pavlik@gmail.com abiryan@ryand.net


  • Needs PHP 5.3 or newer. (uses anonymous functions)

  • You may wish to use git-deploy to push to production, though since this is such a simple little set of php scripts it may be overkill. I've done the git deploy init task already, you just need to do the other ones listed on the git-deploy page.


You'll probably want to fork and tweak things, and that's OK.

  • There are files that end in .sample: rename those to remove that string and edit to customize those details.
    • There are .txt files for the big chunks of text.
    • For indentation, it's easiest to use the config.php instead of a .txt file, which is why it looks like there are two ways of configuring indentation.
  • The files in templates are one place to start. If you add new templates, you'll have to edit common.php to add them to the maps.

The main actual templating code takes place in generate.php.

You can run ./test-locally if you have the php command installed (debian package php5-cli) to simulate a web hit without needing to set up apache and PHP.

Development and Testing

The Makefile is primarily for development, but does have a target to assist with deployment:

  • make or make build - Copies the required files for deployment into BUILD_DIR, defined by default as staging
  • make check - runs PHP in lint mode on the sources
  • make icon - Generates the favicon from SVG source; uses inkscape, pngcrush, and icotool (debian package icoutils)
  • make clean - Removes the staging directory and intermediate files from generating the favicon. (Does not remove the generated files committed to Git.)


The full package is free and open-source software. The main code (in the root directory, templates, and support) are subject to the following license:

Copyright Iowa State University 2012.

Distributed under the Boost Software License, Version 1.0.

(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

The GUID generation code in external/guid.php is used unmodified from http://randomtweak.com/node/54