sschlein/obscure

隐藏您Laravel 5应用中的请求和URL的ID

0.1.0 2016-02-11 19:06 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:36:34 UTC


README

从URL和表单中隐藏ID

Software License Build Status Scrutinizer Code Quality codecov.io StyleCI

隐藏您的Laravel 5应用程序的ID以从URL和请求中。它基于流行的Hashids包

// http://exampleapplication.com/user/ALnLzW

Route::get('/user/{id}', function ($id) {
    return "ID: " . $id; //returns a number
})->middleware('obscure');

内容

## 安装

要将obscure添加到您的项目中,只需将以下内容添加到您的composer.json中:

"sschlein/obscure": "dev-develop" 

然后运行composer installcomposer update

或者,如果您更喜欢,可以运行composer require sschlein/obscure

将服务提供者添加到您的应用程序

在您的config\app.php文件中,将obscure服务提供者添加到providers数组。

    // ...
    Sschlein\Obscure\ObscureServiceProvider::class,
    // ...

在您的.env文件中设置一个盐散列以生成唯一的散列。

OBSCURE_SALT=your-unique-phrase

将中间件添加到您的Kernel中

在您的app\Http\Kernel.php文件中,将obscure中间件添加到$routeMiddleware数组。

protected $routeMiddleware = [
    // ...
    'obscure'         => \Sschlein\Obscure\Middleware\Obscure::class,
    // ...
];
## 使用方法