achinon / yaml_classer
将 YAML 文件转换为可调用的类,方便在 IDE 中引用。
v1.0.4
2024-09-23 14:29 UTC
Requires
- achinon/toolset: ^1.0
- symfony/console: ^7.0
- symfony/framework-bundle: ^7.0
- symfony/yaml: ^7.0
README
将 YAML 文件转换为可调用的类,方便在 IDE 中引用。
设置
要安装此包,请运行 composer require achinon/yaml_classer
。
安装包后,要生成 YAML 文件的 PHP 代码,请使用文件名和您希望它拥有的类名执行命令。
php bin/console achinon:yaml_classer example_config.yml ExampleConfig
PHP 类应被创建。
现在您可以使用依赖注入来访问配置,或者只需创建一个不带任何额外参数的新实例。
如上例所示,导入了 YAML 文件
example: 1 example2: 'example' example3: example4: 'hey' example5: 'hi' example6: example7: - 'hello' - 'sadnioaseinko' example8: "https://github.com/Achinon/yaml_classer/"