GithubHelp home page GithubHelp logo

no22 / picowacore Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 112 KB

PicowaCore (previously called Picowa) is a Sinatra inspired tiny web application framework for PHP 5.2 and later.Although Sinatra-like framework was suitable for small web application, when the scale of the application grows, the problem is caused. When a request comes in, it is necessary already to define or import a lot of event handlers before url mappings whether be actually executed. This framework solves this problem by using lazy callback loading technique.

Home Page: http://github.com/no22/PicowaCore/wiki

License: Other

PHP 100.00%

picowacore's Introduction

PicowaCore
Copyright (c) 2010, 2011 Hiroyuki OHARA 

Document (Japanese)
http://gikoforth.s13.xrea.com/n2/wiki/Picowa

PicowaCore is a Sinatra-like tiny web application framework for PHP 5.2 that was 
derived from Fitzgerald framework and anatoo's Curry, Quotation library and 
inspired by Blanka framework.

Fitzgerald framework:
 http://github.com/jim/fitzgerald

Blanka framework:
 http://github.com/anatoo/Blanka

anatoo's Curry and Quotation library:
 http://d.hatena.ne.jp/anatoo/20090402/1238603946

Example 1 : minimum applicaton

	$app = new Picowa;
	
	$app->get('/','hello');
		function hello() {
			return 'Hello world!';
		}
	
	$app->run();


Exapmle 2 : more object oriented

	class Application extends Picowa {
		public function hello() {
			return 'Hello world!';
		}
	}

	$app = new Application;
	$app->get('/', $app->_hello());
	$app->run();


Exapmle 3 : argument passing

	$app = new Picowa;
	
	$app->get('/:page', bind('get_page',$app), array('page'=>'about|contact|faq'));
		function get_page($app, $page) {
			return $app->render($page);
		}
	
	$app->run();


Exapmle 4 : before filter

	class Application extends Picowa {
		public function hello($name) {
			return "Hello {$name}!";
		}
		
		public function debuglog($args) {
			var_dump($args);
		}
	}
	
	$app = new Application;
	$app->get('/:name', $app->_hello(), array('name'=>'Jon|Ponch'));
	$app->before('get','/:name', $app->_debuglog());
	
	$app->run();


Exapmle 5 : after filter

	$app = new Picowa;
	
	$app->get('/','hello');
	$app->get('/ja/','hello');
		function hello() {
			return 'Hello world!';
		}
	
	$app->after('get','/ja/','translate');
		function translate($text) {
			return strtr($text, array('Hello'=>'こんにちは','world'=>'世界'));
		}
	
	$app->run();


Exapmle 6 : before/around/after filter and execution order

	$app = new Picowa;
	
	$app->get('/','hello');
		function hello() {
			echo __FUNCTION__.',';
			return "Hello world!";
		}
	
	$app->before('GET','.*','before_1');
		function before_1($args) {
			echo __FUNCTION__.',';
		}

	$app->before('GET','.*','before_2');
		function before_2($args) {
			echo __FUNCTION__.',';
		}

	$app->after('GET','.*','after_1');
		function after_1($text) {
			echo __FUNCTION__.',';
			return $text;
		}

	$app->after('GET','.*','after_2');
		function after_2($text) {
			echo __FUNCTION__.',';
			return $text;
		}

	$app->around('GET','.*','around_1');
		function around_1($fn,$args) {
			echo __FUNCTION__.':start,';
			$text = apply($fn,$args);
			echo __FUNCTION__.':end,';
			return $text;
		}

	$app->around('GET','.*','around_2');
		function around_2($fn,$args) {
			echo __FUNCTION__.':start,';
			$text = apply($fn,$args);
			echo __FUNCTION__.':end,';
			return $text;
		}
	
	// before_1,before_2,around_1:start,around_2:start,
	// hello,
	// around_2:end,around_1:end,after_1,after_2,
	
	$app->run();

picowacore's People

Contributors

no22 avatar

Stargazers

quickgreen avatar  avatar David Pennington avatar

Watchers

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