尝试检查您的$laravelSite/config
目录,看看您是否找到一个名为hashids.php
...的文件
在您的控制器中;也尝试Hashids
像这样手动导入类:
<?php
namespace App\Http\Controllers;
use Vinkla\Hashids\Facades\Hashids;
class SampleClass extends {
public function testHashID(){
$h1 = Hashids::encode(4815162342);
var_dump($h1);
$h2 = Hashids::decode('oaobgb-rnar');
var_dump($h2);
}
}
顺便说一下; 如果您没有hashids.php
在您的$laravelSite/config
目录中看到;您可以尝试手动创建它。该文件只返回一个配置设置数组...文件的内容如下所示:
/*
* This file is part of Laravel Hashids.
*
* (c) Vincent Klaiber <hello@vinkla.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return [
/*
|--------------------------------------------------------------------------
| Default Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the connections below you wish to use as
| your default connection for all work. Of course, you may use many
| connections at once using the manager class.
|
*/
'default' => 'main',
/*
|--------------------------------------------------------------------------
| Hashids Connections
|--------------------------------------------------------------------------
|
| Here are each of the connections setup for your application. Example
| configuration has been included, but you may add as many connections as
| you would like.
|
*/
'connections' => [
'main' => [
'salt' => 'your-salt-string',
'length' => 'your-length-integer',
'alphabet' => 'your-alphabet-string',
],
'alternative' => [
'salt' => 'your-salt-string',
'length' => 'your-length-integer',
'alphabet' => 'your-alphabet-string',
],
],
];