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

Something for routing...

posted by s.zares 9 years ago

Hi, Will Thanks for releasing this great tool! I already some times add it in my index.php:

define('URL', fURL::get());

// I need to receive:
// $SEGMENT[n] n-segment value in current URL;
// $LAST_SEGMENT last segment in current URL;
// $LAST_SEGMENT_WOP last segment without page_number_segment ('page2' for example);

define('URL', fURL::get());

if (URL != '' && URL != '/') {
    $parts = explode('/', URL);
    if (count($parts) > 5) { exit('ERROR: Some message...'); }
    $n = 1;
    for ($i = 1; $i < 10; $i++) {
        $SEGMENT[$n] = $parts[$i];
        $n++;
    }
    $LAST_SEGMENT = (substr(URL, -1)  == '/') ? $SEGMENT[count($parts)-2] : $SEGMENT[count($parts)-1];
    $start_ls = substr($LAST_SEGMENT, 0, 4);
    $end_ls = substr($LAST_SEGMENT, 4, strlen($LAST_SEGMENT));
    if ($start_ls == "page" && (preg_match('/^\\d*$/', $end_ls) == 1)) {
        $LAST_SEGMENT_WOP = (substr(URL, -1) == '/') ? $SEGMENT[count($parts)-3] : $SEGMENT[count($parts)-2];
        $PGE_NUMBER = $end_ls;
    } else {
        $LAST_SEGMENT_WOP = $LAST_SEGMENT;
    }
}

// Then...
$_GET['limit'] = $SEGMENT[2];
$limit = fRequest::get('limit', 'integer', 10);

// Or...
$_GET['limit'] = $LAST_SEGMENT_WOP;
$limit = fRequest::get('limit', 'integer', 10);

There are thoughts?

If you are looking for a routing solution, I would recommend checking out Moor.

posted by wbond 9 years ago

Yes, it will solve all my problems, thanks!

posted by s.zares 9 years ago

I've just discovered the Petalon Framework (Moor + Flourish).

Great stuff to organize a project.

http://github.com/zares/petalon

posted by theyouyou 8 years ago

There's also the Slim Framework : http://www.slimframework.com/

posted by theyouyou 8 years ago