faran/pulsar
Composer 安装命令:
composer require faran/pulsar
包简介
An opinionated Laravel architecture for building modular, domain-driven applications at scale
关键字:
README 文档
README
An opinionated Laravel architecture for building modular, domain-driven applications at scale.
Pulsar is an opinionated architecture tool. It provides a strict and explicit approach to organizing Laravel applications using clean architecture, domain-driven design, and service-oriented patterns. This architecture works well for medium-to-large scale applications, multi-tenant SaaS platforms, and teams that benefit from enforced boundaries between business logic and delivery mechanisms. If you prefer Laravel's default structure or flexible, ad-hoc patterns, Pulsar may not be the right fit.
This README is intentionally concise. It defines the architectural contract, not a tutorial.
Table of Contents
- Installation
- Architecture Overview
- Architecture Rules
- File Types
- Commands Reference
- Complete Example
- Contributing
Installation
composer require faran/pulsar --dev
Generate your first service:
pulsar make:service Admin
Architecture Overview
Pulsar organizes your Laravel application into two complementary layers.
- Service Layer — delivery and orchestration
- Domain Layer — business logic
Service Layer
Purpose: HTTP delivery and application orchestration, scoped by consumer audience (Admin, Client, Internal).
app/Services/{Service}/
├── Providers/
│ ├── {Service}ServiceProvider.php
│ └── RouteServiceProvider.php
├── Routes/
│ └── api.php
└── Modules/{Module}/
├── Controllers/
├── Requests/
├── UseCases/
└── Operations/
A Service is:
- A delivery boundary (Admin API, Client API)
- Scoped to a consumer audience
- A logical separation inside a single Laravel application
A Service is NOT:
- A microservice
- A bounded context
- A deployment unit
- An isolated database or schema
Services may share the same database, Domain layer, and deployment.
Domain Layer
Purpose: Business logic independent of delivery concerns (HTTP, controllers).
app/Domain/{Domain}/
├── Models/
├── Actions/
├── DTOs/
├── Policies/
├── Events/
├── Enums/
├── Exceptions/
└── Queries/
The Domain layer is Laravel-first:
- Uses Eloquent models
- Uses Laravel events
- Uses Laravel authorization
- Has zero dependency on Services
It is independent of HTTP, not independent of Laravel.
Architecture Rules
Shared Vocabulary
| Term | Meaning |
|---|---|
| Service | Delivery boundary for a consumer audience |
| Module | Feature slice within a Service |
| Domain | Business capability (Order, Catalog) |
| UseCase | Application workflow |
| Operation | Reusable workflow fragment for UseCases |
| Action | Atomic domain operation |
Service Layer Call Graph
Controllers call UseCases only. Only UseCases call Operations. Multiple UseCases may call the same Operation.
Operations
Operations are reusable workflow fragments shared across UseCases. They may include sequencing and conditional branching decisions. They must never own transactions or emit domain events.
Cross-Domain Logic
Cross-domain coordination belongs in UseCases, never in Actions.
Transactions
UseCases own all transaction boundaries.
Actions and Operations must never manage transactions.
Return Types
Actions and Queries may return domain models, collections, primitives, or void. They must never return HTTP or framework response objects.
Anti-Patterns
- Fat Controllers containing business logic
- Controllers calling Operations directly
- Actions calling other Actions
- Operations emitting domain events
- Transactions inside Actions or Operations
- UseCases calling other UseCases
If you feel tempted to do any of the above, the architecture is being violated.
Why Pulsar Exists
Pulsar optimizes for:
- Team-scale clarity
- Predictable code placement
- Easier PR reviews
- Safer refactors
- Fewer "where does this logic go?" debates
Flexibility is traded for consistency — deliberately.
File Types
Service Layer
| Type | Purpose |
|---|---|
| Service | Bootstrap a delivery boundary |
| Controller | HTTP handling only |
| Request | Validation and authorization |
| UseCase | Workflow orchestration |
| Operation | Reusable workflow fragment across UseCases (branching allowed; no transactions/events) |
Domain Layer
| Type | Purpose |
|---|---|
| Model | Domain entity (Eloquent) |
| Action | Atomic business operation |
| DTO | Data transfer |
| Event | Domain event |
| Enum | Domain state |
| Exception | Business rule violation |
| Query | Read-only domain query |
Commands Reference
Service Layer
make:service {name}make:controller {name} {module} {service} --resourcemake:request {name} {module} {service}make:use-case {name} {module} {service}make:operation {name} {module} {service}
Domain Layer
make:model {name} {domain}make:action {name} {domain}make:dto {name} {domain}make:policy {name} {domain}make:event {name} {domain}make:enum {name} {domain}make:exception {name} {domain}make:query {name} {domain}
Complete Example
See project documentation for a full end-to-end example covering Domain and Service layers.
Contributing
Contributions are welcome. Please follow the architecture rules and existing conventions.
License
MIT License.
Credits
Built with ❤️ by Faran Ali
Inspired by:
- Lucid Architecture
- Clean Architecture
- Domain-Driven Design
faran/pulsar 适用场景与选型建议
faran/pulsar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「crud」 「laravel」 「scalable」 「ddd」 「scaffolding」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 faran/pulsar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 faran/pulsar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 faran/pulsar 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Gii Generator for double model generation
A PSR-7 compatible library for making CRUD API endpoints
Admin panel generator for Laravel 8 and based on Vuetify Admin, a separate SPA admin framework running on top of REST APIs.
Collection of tools to use the full power of the Enyalius framework
Laravel Admin CRUD Generator
Alfabank REST API integration
统计信息
- 总下载量: 43
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-04