rubyqorn/lightweight-router

这是一个PHP库,简化了与您的Web应用程序路由系统的交互

v1.1 2019-07-16 14:33 UTC

This package is auto-updated.

Last update: 2024-09-04 23:27:53 UTC


README

这是一个简单且轻量级的库,可以为您提供关于路由系统的简单表示。

安装

如果您想将此库用于您的Web应用程序,您必须安装composer并使用 composer init 初始化composer.json文件。然后您可以在require块中插入 rubyqorn/lightweight-router,并在CLI中使用 composer install 或直接指定

```php composer require rubyqorn/lightweight-router ```

在哪里注册并查看我的路由?

src/config/routes.php 中,您可以注册将在您的Web应用程序中使用的路由。如果您不想在文件中注册路由,您可以在index.php中引入autoload文件

```php require 'vendor/autoload.php '; ```

并访问路由类

```php use Lightweight\Http\Route; ```

如何使用?

您有四种路由类型

  • GET
  • POST
  • PUT
  • DELETE

示例

```php Route::get('home', 'ExampleController@example'); ```

如果您想在路由中使用参数,您可以使用

  • {slug}
  • {id}

就像这样

```php Route::post('article/{id}', 'ExampleController@example'); ``` ```php Route::delete('article/{slug}', 'ExampleController@example'); ```