Dummy - The framework for Dummies - overview

The basic steps of the Framework are simple:

  1. Your index needs only 2 lines: the require that loads up the framework, and the $Dummy->start call that sets the site folder and key (this is so you can have multiple sites, and the key is a simple safety measure, also used by the administrative pane)
  2. Optionally, instantiate the DefaultDummyController (which has only 4 functions) to have code running on different parts of the framework flow other than the page itself
  3. Make your HTML files using a template where tags are enclosed by braces ({})
  4. Code your page in PHP, you will only need $Dummy->view->assign and $Dummy->view->get most of the time to change things on the template, thought there are other support functions.
  5. Done!

To fully appreciate the simplicity and all features of this minuscule framework, here is a complete workflow (you can find this inside Dummy.php for reference):

First, the workflow starts outside of the $Dummy object, in your index.php at $Dummy->start('site','key'); After that, Dummy will:

  • Create the template by initializing the view object (View object $Dummy->view);
  • Parses the URI in a object URI (URI object $Dummy->uri), from which it will automatically set the array $Dummy->uri->path, string $Dummy->uri->action and can output as $Dummy->uri->toString();
  • Process stored warnings and query from stored session (Dummy allows you to head to another page using the header command, while preserving log and queries from the current page. This is processed here);
  • Checks if the user is accessing the /adm/ and internally fowards to it (uses a different master.php, from /adm/);
  • Set the integer $Dummy->layout mode from extension, $_REQUEST or $_SESSION (layout helps you know if you are serving a normal page, simplified (popup) page, ajax or mobile);
  • Loads, if any, your controller at /site/master.php (in this file you instantiate a DefaultDummyController, as well keep your own "global" functions) into DefaultDummyController object $Dummy->dc;
  • Performs your controller's onStart() function;
  • If it is the case, serves fixed files, like favicon or robots (and ends), as well files inside the vault folder (protected by referer and optional $_SESSION variables);
  • Loads the dinamic configuration file (array $Dummy->dinConfig), which is basically a serialized array in a file stored on your site folder;
  • Creates and configures the database connection (cdbo object $Dummy->db) using delayed connection (only connects if you use the database);
  • Performs your controller's onConnect() function (regardless if really connected or not thanks to the delayed connection);
  • Checks for any registered routes (pages or domains, as well friendly url), which you have set inside your Controller onStart(); ($Dummy->route).
  • Checks for a valid cache of the current page and serves the page (ends here, will run statistics if it is enabled before ending)
  • Loads the HTML file you requested, which should be in your site/Views/, if any. If not found and you have CMS enabled (boolean $Dummy->cms), checks for a CMS page to serve;
  • Records statistics, if you enabled it (boolean $Dummy->keepStatistics);
  • Applies automatic tags in the HTML (remove tags according to layout, adds some constants);
  • Fills out the CMS data in the HTML (automatically fills meta too), if that was the case;
  • Run your PHP file for the page being requested, which should be a .php file with the same name as the page (html) inside /site/Controllers/;
  • Performs your controller's onTerminate(); which also records the cache of any valid page for later use
  • Initiate the termination of the script by filling the debug bar, setting canonicals, setting favicon rel, and outputting headers and the final HTML;

That's it ... that is all the framework does, how many times have you seen the complete detailed workflow of a framework? And if we remove the optional features (admin, CMS and statistics) it would be even smaller!

Since your PHP file runs inside the framework, you can call $this to any $Dummy functions. (see complete framework functions here)

Also, you can use several functions that use Lazy Load by calling them from LazyDummy:: or the alias LD:: (see full list of lazy functions here)

For simple HTML pages, nothing is required. The framework will get the page, process as a template (fill constants and handle layout-related tags) and serve it. Same for CMS pages.

But you can change any HTML by setting a Controller (a .php file with the same name of the requested page in your /site/Controllers folder) to do anything, from process requests to build any customization into the page.