2015-10-15 -- Copyright (C) 2015 Mark Constable (AGPL-3.0)
A very simple PHP7 "framework" that will be expanded to include more small project examples building on the first very lean foundation and incorporating additional functionality in each successive example. This is not a repository of all the attributes of PHP7, there are already many other great projects and pages that provide excellent PHP7 guides, but rather a series of examples that are fully developed under PHP7 (sury/php7.0 PPA on Ubuntu 15.10 2015-09) and taking advantage of any new PHP7-only constructs where it makes sense. Each folder will contain a more comprehensive example of a working, and hopefully useful, sub-project with a README.md explaining each example. This README will provide an overview and index of all examples and some hints that apply to all the sub-project examples.
-
At 132 LOC this is about the simplest 3 page example of this particular framework I could come up with. It is a self-contained single script with all code encapsulated within classes.
-
Funcionally similar to the above barebones example but with a reasonable stylesheet (2.4K 130 sloc) and the Roboto font from Google CDN. It also includes a simple AJAX link on the About page that dumps the main global output array using the ultra simple remote API. There is also an example of passing a success/error message back into the same page but it will be replaced with session vars in one of the next examples.
-
Split up the basic functionality of the previous Styled example into the three traditional model, view, controller (MVC) classes.
-
Add a simple
spl_autoload_register()function to autoload the split out MVC classes. -
Extend the above example to include basic themeing classes and methods.
The associated example README files will act as both code comments and general documentation for each project and an easy way to follow along is to open up two browsers side by side with the README documentation on the left side and drag the reference page line links to the right hand side browser which will highlight the code being discussed.
This function below has proven to be quite useful for examining the code,
assuming you have access to the servers error_log file...
function dbg($var = null)
{
if (is_object($var))
error_log(ReflectionObject::export($var, true));
ob_start();
print_r($var);
$ob = ob_get_contents();
ob_end_clean();
error_log($ob);
}
