toBento/辅助函数

此包已被弃用且不再维护。作者建议使用toBento/service-helper-function包。

支持辅助函数管理。

1.0.4 2023-11-24 08:58 UTC

This package is auto-updated.

Last update: 2023-11-24 08:59:28 UTC


README

使用HelperFunction服务,您可以轻松管理您的辅助函数。

目录

入门

运行此命令添加HelperFunction服务的最新版本。

composer require tobento/service-helper-function

要求

  • PHP 8.0或更高版本

亮点

  • 框架无关,适用于任何项目

示例

以下是使用HelperFunction服务的示例。

// Create Functions.
$functions = new Functions();

// Set any data for later usage for your functions.
$functions->set('sitename', 'Your Sitename');

// Register a function file.
$functions->register(__DIR__.'/functions.php');

// Calling the function registered.
var_dump(sitename()); // string(13) "Your Sitename"

// Get the key set.
$keys = $functions->getKeys(); // ['sitename']

functions.php文件示例。

use Tobento\Service\HelperFunction\Functions;

if (!function_exists('sitename'))
{
    function sitename(): string
    {
        // Get the data from the Functions.
        return Functions::get('sitename');
    }
}

致谢