/AltoRouter

PHP5.3+ Routing Class. Lightweight yet extremely flexible. Supports REST, dynamic and reversed routing.

Primary LanguagePHPMIT LicenseMIT

AltoRouter Build Status Latest Stable Version License Code Climate Test Coverage

AltoRouter는 PHP 5.3+를위한 작지만 강력한 라우팅 클래스로 klein.php에서 많은 영감을 받았습니다.

$router = new AltoRouter();

// map homepage
$router->map( 'GET', '/', function() {
    require __DIR__ . '/views/home.php';
});

// dynamic named route
$router->map( 'GET|POST', '/users/[i:id]/', function( $id ) {
  $user = .....
  require __DIR__ . '/views/user/details.php';
}, 'user-details' );

// echo URL to user-details page for ID 5
echo $router->generate( 'user-details', array( 'id' => 5 ) ); // Output: "/users/5"

특징

  • 모든 HTTP 메소드와 함께 사용할 수 있습니다
  • 명명 된 경로 매개 변수를 사용한 동적 라우팅
  • 역 라우팅
  • 유연한 정규식 라우팅 ([Sinatra] (http://www.sinatrarb.com/)에서 영감을 얻음)
  • 사용자 정의 정규식

시작하기

AltoRouter를 사용하려면 PHP> = 5.3이 필요합니다. 공식적으로 지원되는 PHP 버전을 사용하십시오.

Contributors

License

MIT License

Copyright (c) 2012 Danny van Kooten hi@dannyvankooten.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.