tobento/service-helper-function

支持管理辅助函数。

1.0.4 2023-11-24 08:58 UTC

This package is auto-updated.

Last update: 2024-09-24 10:44:17 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');
    }
}

致谢