11.4. The Skeleton

The script requires a layout to copy from when it creates a new project. I call this the site's skeleton because this layout consists of nothing more than the minimum directories, administration scripts, and configuration files necessary for a new project.

The directories for the skeleton will be: lib, public_files, public_files/css, public_files/img, public_files/js, sql, and templates. A copy of common.php and db.php should be placed in lib. You may want to review Chapter 1 if you aren't well versed in the purpose of each directory and support file at this point.

Rename db.php to db.php.tmp and replace its configuration values with placeholders. startproject will go through and update these placeholders with the values accepted from the developer at the prompts when it goes to copy the skeleton and resave the final file back as db.php.

<?php
// database connection and schema constants
define('DB_HOST', '<tag::db_host>');
define('DB_USER', '<tag::db_user>');
define('DB_PASSWORD', '<tag::db_pass>');
define('DB_SCHEMA', '<tag::db_schema>');
define('DB_TBL_PREFIX', '<tag::db_tbl_prefix>');

...
?>

The skeleton should be saved in a safe place since it will serve as the authoritative blueprint for new projects created by startproject.

Get PHP and MySQL®: Create-Modify-Reuse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.