Boz PHP - Another PHP Framework
To be clear I use to twist this framework very often deprecating and killing stuff how I feel in the morning. It's my custom laser cannon that serves dozen of very-different Content Management Systems "made from zero" in my single Debian GNU/Linux server.
Benefits as developer
You can create a RDBMS CMS with:
- NO PHP SESSIONS
- Resources loaded only when you request them without thinking too much on them (with spl-autoload-register plus a
- No pain with DB table prefixes
- No pain with DB associative options
- No pain with login and user capabilities
- No pain with registering and enqueueing JS and CSS
- No pain with menu trees
- No pain with file uploads
- Very small websites with only what you want in the root of your project
- Very small framework with few flat files
Benefits as sysadmin
- No pain with overweight copy-pasted websites to be hosted with redundant backups and too things to keep updated: The framework is in one place; the websites are in other places; datas are in dabasase/databases. Everything it's how it should be done!
- Do not waste the filesystem file cache feature (feel the pain of your kernel and of your hard-drive cache with
nstand-alone websites without shared resources!)
Obviously a webserver with PHP and MySQL or MariaDB working. Personally I have a simple GLAMP machine (GNU/Linux + Apache + PHP + MySQL or MariaDB). Extra packages suggested:
libmagic-dev package is in the main Debian GNU/Linux repository and so I think it is in all other GNU/Linux distributions. It is needed in order to upload files safetely.
Simplest shared installation
As a shared library: one can serve many sites with a simple
require. Start cloning the source-code in a shared folder as
bzr branch lp:boz-php-another-php-framework /usr/share/boz-php-another-php-framework
That's it! Leave that folder as is, you don't have to touch it anymore.
Go to your website folder (e.g.
/var/www/blog), and create your friendly config file. I use to call it
load.php and please do so. Write in something as:
<?php $username = 'Your database username'; $password = 'The password of your database user'; $database = 'Your database name'; $location = 'localhost'; // Table prefix, if any! $prefix = 'blog_'; // We can wait for this feature.. define('REQUIRE_LOAD_POST', false); // That's it! This will load the framework with the above configurations require '/usr/share/boz-php-another-php-framework/load.php';
And now create your first file e.g.
<?php require 'load.php'; $row = query_row("SELECT NOW() as time"); echo $row->time; echo "If you see the datetime, the database works!";
You can add support for user autentication / user permissions and associative options importing the database schema into your database. To do it you should have received a file called
example-schema.sql in the
examples framework folder. Import it into your database. Actually there are only two tables.
Have to specify these:
string) The database username.
string) The password of the database username.
string) The database name.
string) The database location.
string) The database table prefix.
string) The absolute pathname of your site (
__DIR__is your friend). No trailing slash.
string) The absolute request pathname (something as
/blogor simply an empty string). No trailing slash.
Definibles (as (
false: Enable verbose debugging.
false: It does what you think. Only if
true: To require your
ABSPATH . '/load-post.php.
string): Default is the protocol of the request (
https://). It builds the
string): Default is your domain name. You can override it. It builds the
string): Default is
PROTOCOL . DOMAIN . ROOT.
What you have then
Well. I hope to auto-document it with inline comments. For now you can just see
functions.php in the framework folder.
Own functions / stuff
It's normal to have your own custom configuration of this framework. So the
load-post.php file is made for you. Create it and write in it what you want:
Now remove the declaration of
REQUIRE_LOAD_POST in your
This is a Free as in Freedom project. It comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under the terms of the GNU Affero General Public License v3+.