GithubHelp home page GithubHelp logo

vladis1avlozhkin / fitzgerald Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gregmolnar/fitzgerald

0.0 1.0 0.0 182 KB

A Tiny PHP framework inspired by Sinatra

Home Page: http://autonomousmachine.com/2008/11/21/fitzgerald-a-sinatra-clone-in-php

License: MIT License

fitzgerald's Introduction

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

fitzgerald's People

Contributors

jim avatar gregmolnar avatar gruner avatar sneeu avatar loonkwil avatar tyoro avatar andersonfraga avatar mtorres avatar 4d47 avatar logicabrity avatar

Watchers

Vlad avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.