在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):vinkla/laravel-hashids开源软件地址(OpenSource Url):https://github.com/vinkla/laravel-hashids开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):Laravel Hashids
// Encode integers.
Hashids::encode(4815162342);
// Decode strings.
Hashids::decode('1LLb3b4ck');
// Dependency injection example.
$hashidsManager->encode(911); InstallationRequire this package, with Composer, in the root directory of your project. composer require vinkla/hashids ConfigurationLaravel Hashids requires connection configuration. To get started, you'll need to publish all vendor assets: $ php artisan vendor:publish This will create a Default Connection NameThis option Hashids ConnectionsThis option UsageHere you can see an example of you may use this package. Out of the box, the default adapter is // You can alias this in config/app.php.
use Vinkla\Hashids\Facades\Hashids;
// We're done here - how easy was that, it just works!
Hashids::encode(4815162342);
// This example is simple and there are far more methods available.
Hashids::decode('doyouthinkthatsairyourebreathingnow'); The manager will behave like it is a use Vinkla\Hashids\Facades\Hashids;
// Writing this...
Hashids::connection('main')->encode($id);
// ...is identical to writing this
Hashids::encode($id);
// and is also identical to writing this.
Hashids::connection()->encode($id);
// This is because the main connection is configured to be the default.
Hashids::getDefaultConnection(); // This will return main.
// We can change the default connection.
Hashids::setDefaultConnection('alternative'); // The default is now alternative. If you prefer to use dependency injection over facades, then you can inject the manager: use Vinkla\Hashids\HashidsManager;
class Foo
{
protected $hashids;
public function __construct(HashidsManager $hashids)
{
$this->hashids = $hashids;
}
public function bar($id)
{
$this->hashids->encode($id);
}
}
App::make('Foo')->bar(); For more information on how to use the |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论