ingeniasoftware / luthier-ci

Improved routing, middleware support, authentication tools and more for CodeIgniter 3 framework
https://luthier.ingenia.me/ci/en/
MIT License
150 stars 38 forks source link

route get with parameter #4

Closed haruhinoshana closed 6 years ago

haruhinoshana commented 6 years ago

hi sir can i ask how to make a route on get with parameter like ex: welcome/(:any)

thank you

andersonsalas commented 6 years ago

Hi!

Just enclose it in curly brackets like {this}

Route::get('author/{slug}', ['uses' => 'blog@author', 'as' => 'posts-by-author']);   
//  {slug} => (:any)

Available parameters definitions:

// 1. Anything
// {any: [name]} or simply:
// {[name]}
// Example: {any:foo}, {foo}

// 2. Numeric 
// {num:[name]} 
// Example: {num:bar}

// 3. Custom regex
// {[regex]:[name]}
// Example: '{([0-9]{4}):year}/{([0-9]{2}):month}/{([0-9]{2}):day}'  
robertsanseries commented 6 years ago

@andersonsalas please add this in the documentation!

andersonsalas commented 6 years ago

@robertsanseries that syntax was changed a little bit since the issue date. The current syntax is described in the readme.md file, and the complete documentation can be founded here (english) and here (spanish)