Coder Social home page Coder Social logo

fari-framework's Introduction

Fari Framework (November 2009 - May 2010)

A lean PHP Model-View-Presenter Framework

image

The core framework is very lean (596 lines of code) but still features a loosely coupled template for your projects, automatically filtering user input from forms, providing user authentication, database abstraction layer with field validation, design by contracts, unit testing and showing highlighted syntax in diagnostics class when things go wrong.

The extremely well-commented source code puts Fari Framework among the best 10% of all PHP projects on Ohloh.

Getting started:

The framework has been tested to work on PHP 5.4.4 on Mac OS X Lion through MAMP.

Make sure the /log is writeable.

History:

This project started out as a backend for a CMS developed as part of a BSc. dissertation project. It has later been improved when porting 37Signals' Campfire into PHP.

Documentation:

The API for the core framework is published on GitHub Pages.

Examples:

Model:

<?php

class Albums extends Table {

  /** @var string name of the db table */
  public $tableName = 'albums';

  /** @var array validates the presence of column data */
  public $validatesPresenceOf = array('artist', 'title');

  /** @var array validates the length of columns */
  public $validatesLengthOf = array(array('artist' => 2));

}

Presenter:

<?php

/** ... */

public function actionAdd() {
  if ($this->request->isPost()) {
    try {
      $this->albums->set(array(
        'artist' => $this->request->getPost('artist', 'html'),
        'title' => $this->request->getPost('title', 'html')
        ))->add();

      $this->flashSuccess = 'Album has been saved.';
      $this->redirectTo('/albums/');

    } catch (TableException $e) {
      $this->flashFail = $e->getMessage();
    }
  }

  $this->renderAction();
}

/** ... */

Debugging

Fari Framework automatically understands that you are in development mode, if you call the app from 127.0.0.1. Do so to see a stacktrace of where an error has happened instead of seeing a placeholder error message.

fari-framework's People

Contributors

radekstepan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.