Blueprint PHP Framework Tutorial – Part 1

This tutorial follows on from my introduction to the Blueprint PHP Framework. Last time we looked at why using a framework is a good idea as well a quick overview of this particular framework and a theoretical view of how it works.

Today, I’m going to focus on installing it on your system (‘install’ doesn’t really feel like the right word) and configuring it for your environment. I’ll also give a run down of the components in the framework that you can make use of. Further tutorials will delve more deeply into each of these components.

To get started, clone/download a copy of the PHP framework from github. Then change the settings to suit your environment:

  • Rename .htaccess.default to .htaccess (and set RewriteBase if necessary)
  • Adjust paths in /etc/constants.php (if necessary)
  • Rename /etc/config.default.php to /etc/config.php
  • Set settings in /etc/config.php
  • You must load the /etc/tables.sql into the database

After following these steps you should be able to load the following URLs to test the framework out:

  • /
  • /css-test
  • /test
  • /test/test
  • /test/test/1
  • /test/test/2
  • /test/test/3
  • /test/test/4
  • /test/test/5
  • /secured

These URLs map to the bundled controllers in /app/{namespace}/controllers/. When you’re ready to build your own things with the framework, feel free to delete the ‘Sample’ and ‘Test’ namespaces, and remove them from /app/bootstrap.php.

The bootstrap.php file ties the whole framework together. Without it, the components are just that – a group of components. You can write your own bootstrap script but the one provided does a good job at making everything available to your controllers to pass to views and models.

In the next tutorial I will go through the bootstrap file in detail.

As promised, the components that are bundled with the framework (contained in /lib/Blueprint/):

  • Authentication
  • Autoloader
  • Caching
  • Config
  • Container
  • Controller
  • Database
  • Form
  • Logging
  • Model
  • Page
  • Router
  • Session
  • Table
  • View

The purpose of each of the components is fairly self explanatory by their naming, but I will go through each of them in detail in further tutorials. The components make up the most basic set of functionality that most web apps require and the framework is very flexible in that it can be extended very easily to suit your particular needs.

Until next time…

One thought on “Blueprint PHP Framework Tutorial – Part 1

Leave a Reply