hyperf/pimple
hyperf/pimple 是基于 pimple/pimple 的轻量级 PSR-11 容器组件,提供简单的 ContainerFactory 创建容器与 Provider 注册机制,帮助在非 Hyperf 框架中低成本接入 Hyperf 组件(如 translation/config),便于集成与复用。
hyperf/translation) in Laravel without adopting Hyperf’s full framework. Useful for incremental modernization (e.g., adding Hyperf’s translation system to a Laravel app).ProviderInterface mirrors Laravel’s service providers, easing adoption for Laravel TPMs. However, Hyperf’s make() helper and ApplicationContext are Laravel-foreign, requiring adapters.$container->bind('hyperf.translator', fn() => $pimpleContainer->get(TranslatorInterface::class));
hyperf/translation, hyperf/config, etc., reducing boilerplate for PSR-11 services.hyperf/pimple, hyperf/translation, and hyperf/config to composer.json, which may conflict with Laravel’s ecosystem (e.g., Laravel’s translation system).make() and ApplicationContext, which must be mocked or aliased in Laravel. Example:
// Replace Hyperf's make() with Laravel's app()
$container->set('make', fn($abstract) => app($abstract));
ConfigInterface)?hyperf/translation and hyperf/config conflict with Laravel’s laravel/framework (e.g., duplicate translation files)?Hyperf\Translation vs. Illuminate\Translation)?Mockery, Hyperf’s Mock) to simplify testing?make() or ApplicationContext)?// app/Providers/HyperfServiceProvider.php
use Hyperf\Pimple\ContainerFactory;
use Hyperf\Contract\TranslatorInterface;
class HyperfServiceProvider extends ServiceProvider
{
public function register()
{
$pimple = (new ContainerFactory([
\App\Providers\TranslatorProvider::class,
)))();
$this->app->singleton('hyperf.translator', fn() => $pimple->get(TranslatorInterface::class));
}
}
TranslatorProvider) in Pimple.Mockery or custom test doubles.$this->app->instance(TranslatorInterface::class, Mockery::mock(TranslatorInterface::class));
hyperf/pimple, hyperf/translation, and hyperf/config to composer.json.psr-4 exclusions).How can I help you explore Laravel packages today?