Skip to content
A compact framework for building PHP apps fast with built in SqLite support.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A compact and portable framework for building PHP apps fast with built in SqLite support.

There are many frameworks out there that provide a wealth of features when beginning a new web app. However sometimes all you need are the basics. PaniniPHP provides the following:

  • A simple SEO friendly re-write system that maps (for example) /about.html to /src/about.php
  • A fragment system for loading php blocks to help cut-down re-writing code.
  • Event handling similar to the method WordPress uses.
  • Comes with Twitter Bootstrap out of the box to save you a few minutes (can easily be replaced).
  • SQLite3 Support (with phpLiteAdmin bundle so you can set-up your database).
  • PHPMailer bundled to make sending e-mails less of a chore.


  • PHP 5.4+
  • SQLite 3

Getting Setup

  1. First download a copy of the repo and extract it either into a folder on your WAMP/LAMP (I reccomend XAMPP) or a web server that supports the above requirements. Also you might want to change the folder name to the name of your new app.

  2. Edit config.php which contains a few settings that you might want to change. The following are the most important:

Constant Description
HOME_URL the URL address without trailing / for your app, for example this might be http://localhost/myapp
DB_PATH the path of the SQLite3 database you wish to use, this is already set though so you can leave it as is.
SYS_PASS a password to use for restricting access to specific areas of your app, default is admin.

The config also contains a global array of plugins that you can load from the plugins/ folder, by default you will find PHPMailer in there, however you can add your own if you need extra functionality.

  1. Visit your HOME_URL in a web browser. If everything went ok, you'll see the welcome to PaniniPHP dummy page!

Editing The Database With phpLiteAdmin

Editing your app's database couldn't be easier with PaniniPHP, simply visit HOME_URL\dbadmin and login with the password you set for SYS_PASS.

Creating A New Page

PaniniPHP uses a simple re-write system intended on making app development blazingly fast. Too see it in action try visiting HOME_URL/about.html on your new app and you'll see the About dummy page, that link gets re-written to /src/about.php.

Also try visiting HOME_URL/service.json which you'll find re-writes to /src/service.php.

So to create a new page, all you need to do is add a .php file into the src folder of your new app.

Understanding Fragments

Open src/about.php which should look something like this:

<?= fragment('header', ['title' => 'About Page']); ?>

<div class="container">
  <div class="row">

        <h1>About Page</h1>
        <p>This page is here to demonstrate how the re-write system works.</p>



<?= fragment('footer'); ?>

The function called fragment($slug, $args) is used to load smaller PHP blocks into your pages. These blocks are locaed in src/fragments/ which means fragment('header') will load src/fragments/header.php.

The first argument in the fragment function is the name of the PHP file to include. The 2nd argument is an array of variables that you would like to pass to that fragment. In the case above, title is passed so that the <title> tag can be correctly set.

Accessing The Database

PaniniPHP provides the global variable $db which holds an instance of the JdDatabase class. This allows you to communicate with the database in your pages. Here is an example of how to query and return rows from the database:


    $result = $db->fetch("SELECT * FROM articles");

    foreach ($result->rows as $row) {
      echo '<p>' . $row['name'] . '</p>';


If you would like to execute a command onto the database, you would do something like this:


    $db->exec("UPDATE articles SET name = 'orange' WHERE id = 5");



When a user submits a form, or your app does something, you may wish to alert the user of that action. PaniniPHP provides methods to help you with this. The first is raise_alert($message, $type) which adds a message into the alert stack. $args should always be either ALERT_DEFAULT, ALERT_WARNING or ALERT_ERROR.

The second is get_alerts() which returns an array of alert objects.

For convenience PaniniPHP also provides get_alerts_html() which returns a list of BootStrap alerts in HTML.

Handling Events

Event handling in PaniniPHP is really straight forward. Lets say we wanted to thank the user with an alert when the user logs in. We could write the following:


    handle_event('logged_in', 'my_login_handler');
    function my_login_handler() {
      raise_alert('Thanks for logging in!');


And if we wanted to raise an event in our code, we could write the following:


    function my_function() {


Hint: Having events means you should never need to edit files in the system folder. The intention is that if you wish to handle events, the best place will always be to create a plugin.

Contributing & Support

There is a lot of scope to improve this libarary, but I will be focusing on only merging forks that contribute to the ethos of this project, i.e. to remain compact, mobile and fast. If you have any issues please raise it on GitHub and I'll do what I can.

You can’t perform that action at this time.