Skip to content

gregmolnar/fitzgerald

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

See example.php for a look at how to use Fitzgerald, and read the blog posts: - http://autonomousmachine.com/2008/11/21/fitzgerald-a-sinatra-clone-in-php - http://autonomousmachine.com/2009/2/3/fitzgerald-update-before-filters-and-senddownload

Have fun!

Getting started

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'));
    }
}

Packages

No packages published

Languages

  • PHP 100.0%