View on GitHub

Fitzgerald

A Tiny PHP framework inspired by Sinatra

Download this project as a .zip file Download this project as a tar.gz file

Welcome to Fitzgerald.

Fitzgerald is a tiny PHP framework that was inspired oh so heavily by the wondrous Sinatra of the Ruby world.

Getting started

You can checkout an example app from this repo: fitzgerald-hello_world

Copy the lib folder from the repo to your working directory. Create a file for your application for instance app.php. Inside this file include fitzgerald and subclass it:

include('lib/fitzgerald.php');

class MyApplication extends Fitzgerald {
}

Create an index.php in you DOCUMENT_ROOT and include your app:

include('../app.php');

Create a .htaccess file with the following contents:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

In your app.php file create an instance of the subclacc you made. Add an action to the class and setup a route, than call the run() method of fitzgerald:

include('lib/fitzgerald.php');

class MyApplication extends Fitzgerald {
    public function get_index() {
        return $this->render('index');
    }
}
$app = new MyApplication(array('layout' => 'mylayout'));
// index action
$app->get('/', 'get_index');

$app->run();

Create a layout and a view in the views folder and open the domain in a browser. You should see the contents of the index view.

To pass data to a view you need to pass it to the render function:

class MyApplication extends Fitzgerald {
    public function get_index() {
        return $this->render('index', array('data' => 'my test data'));
    }
}

Authors and Contributors

Fitzgerald built by Jim Benton(@jim) and mantained by Greg Molnar(@gregmolnar).
Contributors: https://github.com/gregmolnar/fitzgerald/graphs/contributors