Skip to content

rubythonode/routes-ci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

routes-ci

Generate routes to Codeigniter framework

#Install

  • create file config/routes-generator.php
  • add next code on file config/routes.php
$file_path = APPPATH . 'config/routes-generator.php';

if(file_exists($file_path)){
	
	$include_route = include $file_path;
	if (isset($include_route) && is_array($include_route))
	{	
		$route = array_merge( $route, $include_route);
	}
}
  • Add the file on FCPATH (home path codeigniter) / **generate-routes.php
  • Define var on **generate-routes.php (not necesary)
define('BASEPATH', str_replace('\\', '/', 'system'));
define('APPPATH',  realpath('app') );

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

  php generate-routes.php

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
  }
}

About

Generate routes to Codeigniter framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages