teksite/module
Composer 安装命令:
composer require teksite/module
包简介
a package to create modules for a laravel project
README 文档
README
A comprehensive Laravel package that brings modularity to your applications. It allows you to organize your code into reusable, self-contained modules — each with its own controllers, models, views, and service providers. The package provides Artisan commands similar to Laravel's native ones, prefixed with module: for easy module management.
Table of Contents
About
The Modular Laravel Package (teksite/module) enables full modularity in Laravel applications. Modules are stored in the Lareon/Modules directory, each replicating a mini Laravel structure. The package mirrors native Laravel Artisan commands but prefixes them with module: to avoid conflicts.
Note: From version 3 onward, this package is merged with
teksite/lareon. Both functionalities are now provided in a single package.
Author
Sina Zangiband
Contact
- Website: teksite.net , laratek.ir , laratek.net
- Email: sina.zangiband@gmail.com
Contact
- Website: teksite.net , laratek.ir , laratek.net
- Email: sina.zangiband@gmail.com
Installation
Compatibility
| Laravel Version | Package Version |
|---|---|
| 11.x | ^1.0 |
| 12.x | ^2.0 |
| 13.x | ^3.0 |
Step 1: Install via Composer
Run the following command:
composer require teksite/module
Note on wikimedia/composer-merge-plugin
If prompted with:
Do you trust "wikimedia/composer-merge-plugin" to execute code and wish to enable it now?
Press y and Enter. This plugin is required to merge composer.json files from modules.
Note on wikimedia/composer-merge-plugin
If prompted with: Do you trust "wikimedia/composer-merge-plugin" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?]
Press y and Enter. This plugin is required to merge composer.json files from modules.
Step 2: Register the Service Provider
Note: For Laravel 5.5 and above, auto-discovery handles this automatically. The following step is optional for newer versions.
Laravel 10 and above
Add the provider to bootstrap/providers.php:
<?php return [ // ... Teksite\Module\ModuleServiceProvider::class, ];
Laravel 5.x and Earlier
Add the provider to config/app.php under providers:
'providers' => [ // ... Teksite\Module\ModuleServiceProvider::class, ],
Step 3: Publish Configuration (Optional)
Publish the configuration files for customization:
php artisan vendor:publish --provider="Teksite\Module\ModuleServiceProvider"
The package publishes two config files:
modules.php– general package behaviormodules-hq.php– control over modules managed by Steward (e.g., routing)
Both are accessible via config('modules').
Step 4: Update composer.json
To enable autoloading of modules and the Steward provider, add the following to your composer.json:
"extra": { "laravel": { "dont-discover": [] }, "merge-plugin": { "include": [ "lareon/steward/composer.json", "lareon/modules/*/composer.json" ] } }
Step 5: Clear Cache
Run the following commands to clear cached data:
php artisan cache:clear php artisan config:clear
Step 6: Refresh Autoloader
Run Composer's autoload dump:
composer dump-autoload
Step 7: Install Steward (Optional but Recommended)
To install Steward, run:
php artisan module:steward
If Steward is not installed, each module must be managed independently.
Usage
Creating a Module
Generate a new module with a structure similar to Laravel:
php artisan module:make Example
Or create a module managed by Steward:
php artisan module:make Example --steward
- By default, modules are created in
lareon/Modules/{Example}. - The
--stewardflag indicates that the module should be managed by Steward (registration of views, configs, routes, etc. are in control of Steward).
Module Commands
All module‑specific Artisan commands are prefixed with module:.
Examples
- Create a controller:
php artisan module:make-controller ExampleController ExampleModule --resource
- Create a model:
php artisan module:make-model ExampleModel -a ExampleModule
- Create a middleware:
php artisan module:make-middleware ExampleMiddleware ExampleModule
- And other laravel command.
Note: Replace
ExampleModulewith your actual module name. To create files inside Steward (instead of a module), useStewardas the module name.
Changing Module Priority
To adjust the loading order of modules, edit the bootstrap/modules.php file. Reorder the array to prioritize specific modules:
<?php return [ 'Blog' => [ 'provider' => 'Lareon\\Modules\\Blog\\App\\Providers\\BlogServiceProvider', 'active' => true, 'type' => 'lareon', ], 'Page' => [ 'provider' => 'Lareon\\Modules\\Page\\App\\Providers\\PageServiceProvider', 'active' => true, 'type' => 'self', ], ];
Change Mode
To switch an existing module between steward‑controlled (steward) and self‑managed (self), update the type in bootstrap/modules.php:
'Example' => [ 'provider' => 'Lareon\\Modules\\Example\\App\\Providers\\ExampleServiceProvider', 'active' => true, 'type' => 'steward', // change to 'self' for self‑managed or steward to managed by Steward ],
and update the $type property in {ModuleName}ServiceProvider:
/** * Module type (self|steward) * * @var string */ protected string $type = "steward"; // change to 'self' for self‑managed or steward to managed by Steward
Integration with Lareon
This package is now merged with teksite/lareon. The main difference in naming is steward instead of previous terms like cms.
To switch an existing module between steward-controlled (steward) and self-managed (self), update the type in bootstrap/modules.php:
'Example' => [ 'provider' => 'Lareon\\Modules\\Example\\App\\Providers\\ExampleServiceProvider', 'active' => true, 'type' => 'steward', // or 'self' ],
and update {ModuleName}ServiceProvider
/** * Module type (self|steward) * * @var string */ protected string $type = "steward"; //self to managed by the module itself or steward to manage by Steward
Warning: Changing between these two modes generally does not cause issues, provided you do not override internal methods.
Credits
License
This package is open‑sourced under the MIT License.
Support
For questions, issues, or feature requests, please reach out via:
- Website: teksite.net
- Email: sina.zangiband@gmail.com
- GitHub Issues: teksite/module
Contributions are welcome! Feel free to submit a pull request or open an issue on GitHub.
teksite/module 适用场景与选型建议
teksite/module 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 01 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「module」 「modules」 「laravel」 「modularity」 「lareon」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 teksite/module 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 teksite/module 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 teksite/module 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This is Paymorrow module for OXID eShop.
Analysis module for finding problematical shop data.
yii2 swiper slider
An interactive tour through the TYPO3 backend.
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
Yii2 module to manage website content. Kind of a CMS...
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-25