magedahmad/insular
Composer 安装命令:
composer require magedahmad/insular
包简介
An architecture for scalable software.
关键字:
README 文档
README
Insular is a software architecture to build scalable Laravel projects in a modern, clear and modular way.
Insular is latin word which means "Having a narrow view of the world." and that is how modules are suppose to be structured. 🔥🔥
Table of contents
- Installation
- Snowflake
- Available commands
- Managing Modules
- Managing Features
- Managing Operations
- Managing Jobs
- Managing Controllers
- Managing Migrations
- Managing Models
- Managing Resources
- Managing Requests
- Managing Types
- Managing Exception
Installation
You can install the package via composer:
composer require MagedAhmad/insular
Snowflake
We use snowflake for ids, by default newly created models with the custom command will use the Snowflake trait. you can read more about snowflake here
Available commands
| Target | Command |
|---|---|
| Create new module | php artisan create:module $name |
| Create new feature | php artisan create:feature $name $module |
| Create new operation | php artisan create:operation $name $module |
| Create new job | php artisan create:job $name $module |
| Create new controller | php artisan create:controller $name $module |
| Create new migration | php artisan create:migration $name $module |
| Create new model | php artisan create:model $name $module |
| Create new type | php artisan create:type $name $module |
| Create new resource | php artisan create:resource $name $module |
| Create new request | php artisan create:request $name $module |
| Create new exception | php artisan create:exception $name $module |
Modules
You start by building the main block in your application which is a Module.
Modules are like mini laravel applications where each module contains everything needed to build this module.
php artisan create:module $name
example:
php artisan create:module Auth
this will create module structure in Modules\Auth
Features
Feature can be used when you have multiple operations related to some action and you would repeat these operations more than once, so you can create a feature and reuse it later on.
php artisan create:feature $name $module
example:
php artisan create:feature LoginUserFeature Auth
this will create feature in Modules\Auth\Features\LoginUserFeature
Operations
Operation is the main building block where most logic would go, it might contain multiple jobs.
php artisan create:operation $name $module
example:
php artisan create:operation LoginUserOperation Auth
this will create file in Modules\Auth\Operations\LoginUserOperation
Jobs
Jobs are the smallest unit on our system. you can use it to avoid duplication of small shrunks of code . you should only use it when you are sure that you would use it multiple times, otherwise operation should be just fine to hold the logic in it.
php artisan create:job $name $module
example:
php artisan create:job LoginUserJob Auth
this will create file in Modules\Auth\Jobs\LoginUserJob
Controllers
php artisan create:controller $name $module
example:
php artisan create:controller LoginController Auth
this will create file in Modules\Auth\Http\Controllers\LoginController
Migrations
you only need to write the migration name like users, products, categories, no need to type create_users_table .
php artisan create:migration $name $module
example:
php artisan create:migration users Auth
this will create file in Modules\Auth\database\migrations\users
Models
Models use snowflake trait by default
php artisan create:model $name $module
example:
php artisan create:model User Auth
this will create file in Modules\Auth\Models\User
Resources
Resources can be used to map data before sending in the response .
php artisan create:resource $name $module
example:
php artisan create:resource UserResource Auth
this will create file in Modules\Auth\Http\Controllers\Resource\UserResource
Requests
can be used for validating incoming request data .
php artisan create:request $name $module
example:
php artisan create:request UserRequest Auth
this will create file in Modules\Auth\Http\Controllers\Requests\UserRequest
Types
Types can be used for internal handling of data between classes
php artisan create:type $name $module
example:
php artisan create:type UserData Auth
this will create file in Modules\Auth\Types\UserData
Exception
php artisan create:exception $name $module
example:
php artisan create:exception UserNotFoundException Auth
this will create file in Modules\Auth\Exceptions\UserNotFoundException
Testing
vendor/bin/pest
TODO
1- Work on a global response for all requests. 2- Provide easy way to test/view apis. 3- Switch between Pest and phpunit
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
magedahmad/insular 适用场景与选型建议
magedahmad/insular 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 12, 最近一次更新时间为 2022 年 11 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「magedahmad」 「insular」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 magedahmad/insular 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 magedahmad/insular 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 magedahmad/insular 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-02