2016-03-30 5 views
0

Wie kann ich oder-Option in der Slim 3 routes haben?Slim 3 - wie oder Option in die Route hinzufügen?

Zum Beispiel ist es das, was ich zur Zeit:

// Home page. 
$app->get('/', function (Request $request, Response $response, array $args) { 
    // Get the application settings. 
    $settings = $this->get('settings'); 

    // Check if the home page class is provided. 
    ... lots of codes 
}); 

$app->get('/home', function (Request $request, Response $response, array $args) { 
    // Get the application settings. 
    $settings = $this->get('settings'); 

    // Check if the home page class is provided. 
    ... lots of codes 
}); 

anstatt die Stücke dieser Codes zu wiederholen, kann ich sie in einer wie machen:

$app->get('/ or /home', function (Request $request, Response $response, array $args) { 
...} 
+2

Ist nicht [optionale Segmente] (http://www.slimframework.com/docs/objects/router.html#optional-segments) ist was du willst? –

+0

ja ist es! Danke! – laukok

+1

@EvgenySoynov Fügen Sie bitte Ihren Kommentar als Antwort hinzu. Dann kann das OP es akzeptieren. –

Antwort