PHP code example of pyrsmk / longuevue

1. Go to this page and download the library: Download pyrsmk/longuevue library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pyrsmk / longuevue example snippets


$longuevue=new LongueVue('/articles/{id}/comments');
// Will return false
$longuevue->match('/articles');
// Will return false too
$longuevue->match('/articles//comments');
// Will return array('id'=>'72')
$longuevue->match('/articles/72/comments');
// Will return array()
$longuevue->match('/articles//comments');

$longuevue=new LongueVue('/articles/{id}/comments');
$longuevue->addValidator('id','\d+');
// Match
$longuevue->match('/articles/72/comments');
// Won't match
$longuevue->match('/articles/some_article/comments');

$longuevue=new LongueVue('/articles/{id}/comments');
$longuevue->addDefaultValue('id','1');
// Will return array('id'=>'72')
$longuevue->match('/articles/72/comments');
// Will return array('id'=>'1')
$longuevue->match('/articles//comments');