From eaa9c99dd711ca5c4fd077a2e193b06625f6d87f Mon Sep 17 00:00:00 2001 From: Yuriy Tkachenko Date: Thu, 10 Mar 2016 09:52:18 +0300 Subject: [PATCH 1/2] Updated README.md Added example for routing object methods --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 84c6290..3876db1 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,24 @@ class Greeting { } } -Flight::route('/', array('Greeting','hello')); +Flight::route('/', array('Greeting', 'hello')); +``` + +Or an object method: + +```php +class Greeting +{ + public function __construct() { + $this->name = 'John Doe'; + } + + public function hello() { + echo "Hello, {$this->name}!"; + } +} + +Flight::route('/', array(new Greeting, 'hello')); ``` Routes are matched in the order they are defined. The first route to match a From e42d4ad7f9138056524157faab2b63668d4d7074 Mon Sep 17 00:00:00 2001 From: Yuriy Tkachenko Date: Mon, 28 Mar 2016 21:53:16 +0400 Subject: [PATCH 2/2] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3876db1..75f99be 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,9 @@ class Greeting } } -Flight::route('/', array(new Greeting, 'hello')); +$greeting = new Greeting(); + +Flight::route('/', array($greeting, 'hello')); ``` Routes are matched in the order they are defined. The first route to match a