mikelooper/container-settings

0.0.5 2024-03-11 19:17 UTC

This package is auto-updated.

Last update: 2024-09-11 20:16:45 UTC


README

这个包提供了一个名为 ContainerFactory 的工厂,使用 PHP-DI 的 PSR-11 容器。这个容器将有一个 SettingsInterface 的实现,该实现允许使用“点注解”访问设置。此外,您可以使用缓存功能来优化项目中的性能。

使用示例

要使用此包,您需要创建一个文件或数组,如果使用文件,则必须返回该文件中的数组。以下是一个使用示例

// settings.php
return [
    'foo' => [
        'bar' => 1
    ]
];
// index.php
use ContainerFactory;

$settingsPath = __DIR__ . '/settings.php'; // or array
$container = ContainerFactory::create($settingsPath);

$settings = $container->get(SettingsInterface::class');
$number = $settings->get('foo.bar');
echo $number; // 1

制作命令

$ make help

Usage: make [target] ...

Container:
  run                 Build and run php container
  build               Build php container
  stop                Stop php container
  destroy             Remove all data related with php container
  shell               SHH in container
  logs                Show logs in container
                      
Miscellaneous:
  help                Show this help
                      
Code:
  exec                Execute composer commands
                      
Tests:
  test                Execute tests
  test-coverage       Execute tests with coverage
                      
Style:
  lint                Show style errors
  lint-fix            Fix style errors
                      
Written by Antonio Miguel Morillo Chica, version v1.0
Please report any bug or error to the author.