huangdijia / hyperf-config-array
Config extension for Hyperf.
0.1.1
2020-11-26 01:33 UTC
Requires
- php: >=7.2
- hyperf/utils: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- hyperf/command: ^2.0
- hyperf/di: ^2.0
- hyperf/event: ^2.0
- hyperf/framework: ^2.0
- hyperf/process: ^2.0
- hyperf/server: ^2.0
- hyperf/testing: ^2.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^7.0|^8.0|^9.0|^10.0
- swoole/ide-helper: ^4.5
README
Installation
composer require huangdijia/hyperf-config-array
Publish
php bin/hyperf.php vendor:publish huangdijia/hyperf-config-array
Define source
namespace App\Source; use Huangdijia\ConfigArray\SourceInterface; use Hyperf\DB\DB; class DBSource implements SourceInterface { public function toArray(): array { return DB::query('SELECT * FROM `config`;'); } }
Set config
// config/autoload/config_array.php return [ // ... 'source' => App\Source\DBSource::class, // ... 'mapping' => 'setting', // using as config('setting') // or 'mapping' => [ 'setting_key' => 'setting.key', // using as config('setting.key') ], ];