Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

jpachecox/Dynamic-Routes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

20 Commits

Repository files navigation

Dynamic Routes for CodeIgniter 3.*

Generate Dynamic Routes to Codeigniter into Controllers

Requirements

  • php-5.* or php-7.*
  • FrameWork CodeIgniter 3.*
  • linux or sh command

Install

  • Download DynamicRoutes.php into libraries/
  • Download dynamicRoutes (sh) into path framework
  • Edit file config/routes.php
include_once APPPATH .'/libraries/DynamicRoutes.php';
$DynamicRoutes = new DynamicRoutes([
	'format' => 'json'
]);
$route = array_merge( $route, $DynamicRoutes->current_routes );
  • Config dynamicRoutes

Remember! that you change the comment after a route only run the following in console

 php dynamicRoutes

Examples

route controller + function

/**
 * @route:example-route
 */
class Example1 extends CI_Controller
{
 /**
 * @route:product/(:num)
 * @route:product
 */
 function product( $parm ){
 //url1: /example-route/product/1
 //url2: /example-route/product
 }
}

route on function

class Example2 extends CI_Controller
{
 /**
 * @route:hello-world
 */
 function hello_world( ){
 //url: /hello-world
 }
 
 /**
 * @route:hi-moon
 */
 function hello_moon( ){
 //url: /hi-moon
 }
}

arguments num and any

/**
 * @route:arguments
 */
class Example3 extends CI_Controller
{
 /**
 * @route:numeric-values/(:num)/(:num)
 */
 function numeric( $a , $b ){
 //url: /arguments/numeric-values/1ドル/2ドル
 }
 
 /**
 * @route:any-values/(:any)
 */
 function any( $a ){
 //url: /arguments/any-values/1ドル
 }
 
 /**
 * @route:several/(:num)/(:num)/(:any)/(:any)
 */
 function several( $a, $b , $c, $d ){
 //url: /arguments/several/1ドル/2ドル/3ドル/4ドル
 }
}

Include method get, post, put, delete

/**
 * @route:example4
 */
class Example4 extends CI_Controller
{
 /**
 * @route:{post}data_post
 */
 function data_post(){
 //url: example4/data_post/ method = post
 }
 
 /**
 * @route:{get}my_data_get
 */
 function my_data_get(){
 //url: /example4/my_data_get/ method = get
 }
}

About

Generate routes to Codeigniter framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%

AltStyle によって変換されたページ (->オリジナル) /