定制 switon/di 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

switon/di

Composer 安装命令:

composer require switon/di

包简介

Property-based dependency injection with interface autowiring, named slots, and shared versus fresh instances for Switon Framework

README 文档

README

CI PHP 8.3+

Switon's dependency injection container for autowiring, named services, and bootstrap wiring.

Highlights

  • Shared container: ContainerInterface handles service resolution and definition registration.
  • Service autowiring: #[Autowired] can inject object services without manual lookups.
  • Config autowiring: the same attribute can fill scalar and array properties from config.
  • Named instances: FactoryInterface supports multiple implementations of the same type.
  • Lazy dependencies: Lazy defers non-default resolution until a value is actually used.
  • Autowired instances: #[Autowired(instances: true)] can inject service arrays from config.

Installation

composer require switon/di

Quick Start

# switon.yml
Switon\Core\AppInterface:
  id: admin
  name: Admin Panel
  version: 2.0.0
  env: dev
  debug: true
  timezone: Asia/Shanghai
use Switon\Core\AppInterface;
use Switon\Core\Attribute\Autowired;

class DashboardService
{
    #[Autowired] protected AppInterface $app;

    public function title(): string
    {
        return $this->app->name() . ' (' . $this->app->env() . ')';
    }
}

Docs: https://docs.switon.dev/latest/di

License

MIT.

统计信息

  • 总下载量: 69
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 10
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固