Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

Routing

posted by dragos 9 years ago

I read I a previous post that you recommended moor class for routing. I know it's not relating on flourish but please can you tell me in 2-3 lines how can use it with flourish. i want to use it like zend style to have a folder controller and class Users extends !MoorAbstractController. I set in bootstrap Moor::route('/users/', 'list'); Moor::run(); and in url Users/list but i can get any results, it seems that

if (!preg_match($route->url->pattern, self::$request_path, $matches)) {
	return FALSE;
}

in Moor::dispatch() return false. Thanks.

Here's an example of Flourish + Moor. fm.cc Warning: No stable!!!

posted by s.zares 9 years ago

Tanks.

posted by mungiu 9 years ago

I pasted the example on my windows server and it's not working. Must change some configuration?

posted by dragos 9 years ago

Hello, I'm the author of Moor.

In the example, your route is going to look for a global function list. We can't use list as a function name because it's a reserved word in PHP. :-) So in the following examples, I am going to rename list to browse.

// Link to a global function action

Moor::route('/users', 'browse');

function browse() {
   echo 'Hello from browse!';
}

Moor::run();

If you want to route to a method within a class that extends a MoorActionController class:

// Link to Moor Controller method action

Moor::route('/users', 'Users::browse');

class Users extends MoorActionController {
	public function browse() {
		echo 'Hello from browse!';
	}
}

Moor::run();
posted by jeffturcotte 9 years ago

Your can use the some example Flourish with Moor on Git http://github.com/zares/petalon

posted by s.zares 9 years ago