This framework contains classes that simplify routine tasks, without added load of unwanted logic. There are many frameworks loaded with logic already. This framework tries to follow the UNIX philosophy.
For example, the database code provided by this framework only wraps PDO, without handling schema changes. Tools to handle database schema already exist. The database class only creates a PDO connection using configured target and credentials, sets up the connection properly (UTF-8 and stuff), and does some always needed functions, such as fetchAll and query loggin (to the standard error log). Ther is some [support for transactions].
Models only provide convenience methods for reading and writing rows, converting them to object with specified fields, the rest you do with SQL. If you only need simple operations, then there are built-in methods for selecting all models or by key, creating, updating and deleting them. If you need complex queries, even with joins and subqueries -- no need to learn complicated query builder syntax, just write an SQL query. Also, you can even have models that use a text/csv file instead of a database.
Templating is handled similarly. Template engine accepts an array of data and returns a text string. By default Twig is used, but Smarty or another engine can easily be used, see HOWTOs.
And so on.
By default, config file is read from src/config/settings.php.
It returns a key-value array of settings, which are accessible by class Framework_Config.
The default config file also reads
settings.php from the
See HOWTO_configuration for details.
Reads src/config/routes.php, which returns an array which describes the route map.
Each element contains a
REQUEST_URI pattern, a method mask and a class name.
(Requests of different methods can be handled by different classes.)
Handlers must be descendants of Framework_View.
See Framework_Router or HOWTO_routing for details.
Background task execution. Tasks are queued (added to the database), then executed by a dedicated queue processor. Typically, long running tasks hungry for resources, like image and video transcoding, are done this way.
Tasks are identified by a string, which is routed through src/config/tasks.php, similar to web requests. Successfully finished tasks are deleted, other are retried after a while.
Tasks are executed by a dedicated PHP process, outside of the web server loop. There is a supervisor, which restarts the queue processor if it crashes. Tasks with problems (exceptions or crashes) are postponed and repeated later.
There is a simple base class for database access. Might look like ORM, but it's not. Just a handy way of reading database records and mapping them to classes. Has some built-in methods to read by id, save, delete, etc. To select objects by a filter you'll need to use SQL, which is designed exactly for this. There is a cursor class which helps reading lots of records without hitting the memory limit.
It compiles large files from parts you specify, minifies them as needed.
Puts results where you tell it to (
src/static by default).
See dev/compile_assets.php for details.
The whole application is packaged in a single PHAR file. Including templates, assets and other static files (which however can be easily deployed to the file system). This makes it easy to install and deploy the application. See dev/build.php for details.
Built in examples and snippets
When I use this framework, I put my application in the src/vendor/App folder. I used to have a project-named folder, like src/vendor/TreeDB, but this way I can easily copy modules from one project to another without having to rename classes and track dependencies.
With this in mind, I created an src/vendor/App folder in this framework as an example and a repository of modules to quick-copy from. Or I can even just add them to the route map and use unmodified.
src/vendor/App/Articles (and a model aside).
Article manager in its simplest form. It can display an article, a list of them, edit existing and create new articles. Which have a title and a body, which is formatted with Markdown. Articles can be optionally published, can have or not public access (e.g., visible only to registered users). Templates are also available, namely the editor is ready to use.
Some websites using this framework
To report bugs or suggest a feature, email me at firstname.lastname@example.org.