toBento/辅助函数
1.0.4
2023-11-24 08:58 UTC
Requires
- php: >=8.0
- psr/container: ^1.0 || ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^4.0
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'); } }