2017 © Pedro Peláez
 

library tp5-route-helper

this library can helper to build tp5 route rule

image

saberyjs/tp5-route-helper

this library can helper to build tp5 route rule

  • Sunday, March 11, 2018
  • by saberyjs
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

thinkphp5-route-helper

this library help register route auto, write less,make develop better, (*1)

introduce

if you have ever use thinkphp5 route ,you will feel exhausted ,because if you want register route rule,you must provide it in a file called route.php (maybe call some other name), so i write this tool,its his role like JAVA web route., (*2)

how to use

it is very easy to use this library. - create object of RouterHelper - call method called register, (*3)

code is here:, (*4)

$routeHelper = new \saberyjs\tp_route_helper\RouterHelper();
$routeHelper->register([
    ['index',APP_PATH]
]);

what you need is create a instance of RouterHelper,and call register method on it, (*5)

how to define class or method

to use this library ,you must provide some annotation when you write your controller, assuming we want write a controller class called User:, (*6)

/**
 * @auto true
 * @https false
 * **/
class Index
{
    /**
     * @rule /home/:id/:token
     * @alias home
     * @https false
     * @method get|post
     * @ext html|shtml
     * @deny_ext  htm
     * @constraint  id  \d{1,5} token  \w+
     * **/
    public function index($id)
    {
        echo  Route::class;
    }
}

code is very simple,the annotation of getOrder explain that this method should request by GET or POST, and http protocal should be https,last,param id should only be number(max length is 4),if you do not remember thinkphp5 route ,you should read it first., (*7)

some tips

when you create RouteHelper,you can provide two args,$namespace and Parser,$namespace specify base namespace,but you may not provide because library provide a default value(app,it`s value is equal APP_NAMESPACE constant). $parser is a obejct that implement Parser interface,more detail,please look for AnnotationHeper,it is responsible for parse annotation for php code., (*8)

cache routes

in production environment,route rules is cached,actually,it depends on a config item called app_debug,if it`s value is equal to false,rules will be cached in the path(RUNTIME_PATH/routes.json)., (*9)

contact

email:saberyjs@gmail.com QQ:1174332406, (*10)

The Versions

11/03 2018

dev-master

9999999-dev

this library can helper to build tp5 route rule

  Sources   Download

MIT

The Requires

 

by Avatar saberyjs

11/03 2018

2.2.1

2.2.1.0

this library can helper to build tp5 route rule

  Sources   Download

MIT

The Requires

 

by Avatar saberyjs

11/03 2018

2.2

2.2.0.0

this library can helper to build tp5 route rule

  Sources   Download

MIT

The Requires

 

by Avatar saberyjs

11/03 2018

2.1

2.1.0.0

this library can helper to build tp5 route rule

  Sources   Download

MIT

The Requires

 

by Avatar saberyjs

11/03 2018

2.0

2.0.0.0

this library can helper to build tp5 route rule

  Sources   Download

MIT

The Requires

  • php >5.6

 

The Development Requires

by Avatar saberyjs