Skip to content
An MVC PHP framework for web applications.
PHP JavaScript Shell
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
app
scaffolding
scripts
www
.gitattributes
.gitignore
README.md
index.html

README.md

Welcome

Scaffolding is a lightweight PHP-based framework that uses the MVC paradigm. It's designed to be fast in both performance and development time.

Features

  • Lightweight: simple, intuitive design that lets you simply start coding.
  • Built-in performance profiling: just one line of code to enable, and one line per profiling point.
  • Upgrading is easy: designed to separate app code from the core framework. Keep one copy of the framework for all of your projects if you wish, or use a new copy for each.

Try it

First, grab a copy of the framework, open it up and initialize your configuration. On Mac or Linux, from the root directory of the framework, you can run:

$ chmod +x ./scripts/setup-posix.sh
$ ./scripts/setup-posix.sh

Or on Windows:

> setup-windows.bat

Setup/deployment/testing

Paths to the app/ and scaffolding/ directories are set in www/index.php. If you choose to set up your app so that application code is further removed from the document root, you'll need to alter these path definitions appropriately.

Subdomain/virtualhost

Your document root should be the www/ directory of your app. In Apache, your VirtualHost directive might look like:

<VirtualHost *:80>
    DocumentRoot "/home/jimmy/my_web_app/www"
    ServerName webapp.jsawdev.local

    <Directory /home/jimmy/my_web_app/www>
        AllowOverride All
    </Directory>
</VirtualHost>

Subdirectory

If you want your site to live at http://www.domain.com/directory, the www directory will need to be in your document root for that domain and be renamed to whatever you want the directory to be, and you'll need to move your app/ and scaffolding/ directories somewhere and point to them from your index.php file in your directory. Additionally, you'll need to prefix the default route in app/config/routes.php with the path off the domain to your directory, i.e. directory.

Of these two options, I recommend subdomain development and deployment.

Features

Profiling

Profiling (as provided by @jimrubenstein's Profiler class) is enabled by default. It needs to start as early as possible, so it's enabled in www/index.php, before almost anything else happens. If you wish to enable it later in the request (so you can base it off of a Session value or something), you'll need to comment out the Profiler::enable() call there.

Rendering the profiling output requires jQuery to run and google-code-prettify for styling, copies of which are included in this framework. You can conditionally render the profiler output via a config value (see app/config/config.sample.php for details).

Version tracking

Scaffolding features a built-in class for parsing and rendering a version snippet on your web page so you can easily determine what version of your code a certain deployment is running. Enabling this requires installing hooks on either your Git or Hg repository. They look like this:

Git hook

Run on post-merge, post-commit and post-checkout:

./scripts/git-hook

Hg hook

Run on post-update and post-commit):

hg log -r . --template "hg\n{rev}\n{node|short}\n{node}\n{date|isodate}\
    {branches}\n{tags}\n{author|person}\n{author|email}\n\n{desc}\n"

Configuration management

Easily manage multiple configurations for multiple environments by using the built-in Config class. It's pretty simple: use set() to set up values on different config modes, and get() to retrieve them. We set the mode in a file not in version control (app/local_config.php) via Config::setMode(), and then:

<?php
// set local IP
Config::set('dev', 'server_ip', '127.0.0.1');

// get local IP
echo Config::get('server_ip');

Library loader

Rather than managing your external libraries or includes yourself, just throw them in app/lib or scaffolding/ext and use Library::load($name). This will search those folders for a file of the same name (all lowercase). For example, if we're trying to load facebook_twitter_pinterest.php, simply use: Library::load('FacebookTwitterPinterest');. (Note that camelcase libraries point to underscored filenames).

Feedback

Feel free to drop me a line at scaffolding@jimmysawczuk.com or report an issue with any feedback you might have, even if it's just to tell me you're using the framework! I'm trying to make this framework an excellent option for as many PHP developers and as many projects as I can, and I promise I will read and consider any feedback.

Contributions

Scaffolding uses or redistributes code from these open-source projects.

License

The MIT License (MIT)
Copyright (C) 2010-2013 by Jimmy Sawczuk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Something went wrong with that request. Please try again.