vdlp / oc-hashids-plugin

允许开发者在由October CMS驱动的网站上使用安全的哈希ID。

安装量: 15,806

依赖关系: 0

建议者: 0

安全: 0

星标: 4

关注者: 8

分支: 0

开放性问题: 0

类型:october-plugin

2.2.0 2022-11-28 09:05 UTC

This package is auto-updated.

Last update: 2024-09-14 14:50:29 UTC


README

Vdlp.Hashids

允许开发者使用安全的哈希ID。

抓取RSS/Atom源以放置在您的网站上。可以使用cron作业或手动触发。

它可以将数字(如347)转换为字符串(如"yr8"),或者将数字数组(如[27, 986])转换为"3kTMd"。

您也可以解码这些ID。这有助于将多个参数打包到一个ID中或简单地作为简短的UID使用。

要求

  • PHP 8.0.2或更高版本
  • October CMS 2.x或更高版本

安装

composer require vdlp/oc-hashids-plugin

配置

要配置此插件,请执行以下命令

php artisan vendor:publish --provider="Vdlp\Hashids\ServiceProvider" --tag="config"

这将创建一个config/hashids.php文件,您可以在其中修改配置。

示例

在这里您可以看到如何使用此插件的示例。默认情况下,使用的是main配置。

// You can use this class with Dependency Injection
use Vdlp\Hashids\Classes\HashidsManager;

/** @var HashidsManager $hashids */
$hashidsManager = resolve(HashidsManager::class);

// Encodes the integer 1 to a hashid using the default configuration
$hashidsManager->encode(1);
$hashidsManager->instance()->encode(1);

// Encodes the integer 1 to a hashid using a different configuration
$hashidsManager->instance('different-configuration')->encode(1);

有问题吗?需要帮助?

如果您对如何使用此插件有任何疑问,请随时通过octobercms@vdlp.nl与我们联系。我们很乐意帮助您。您也可以访问支持论坛,并在那里提出问题/问题。