Skip to content

Packagit is amazing laravel modules management, you could manage huge project with many separate laravel modules.

License

Notifications You must be signed in to change notification settings

packagit/packagit

Repository files navigation

Packagit

Packagit is amazing laravel modules management, you could manage huge project with many separate laravel modules.

You could runpackagitor a short namep,such asp new Auth,a module named Auth would be created.

You can make artisan command running anywhere, All the packagit commands are same with artisan like following table.

artisan packagit
php artisan tinker p tinker
php artisan make:controller p make:controller
php artisan make:migration p make:migration
php artisan make:job p make:job
php artisan test p test
php artisan... p...

for example, you have a project namedstarter,directories layout:

starter
└── modules
├── Auth
├── Components
└── Wechat

change path tostarter/modules/Auth,and runp make:controller:

cd starter/modules/Auth
p make:controller DemoController

DemoController.php would be created for Auth module.

modules/Auth/src/Http/
└── Controllers
└── DemoController.php

change path tostarter/app/Http/Controllers,andp make:controller:

cd starter/app/Http/Controllers
p make:controller DemoController

DemoController.php would be created for starter, because of current path doesn't include any module.

So when you runp make:xxxlaravel command, packagit would scan the path, if current is in a module path, it will create for the module, otherwise for the project.

Installation

composer global require packagit/packagit

You MUST installpackagitwithglobal,and add composer bin to the $PATH environment.

Following command would help you find the global bin path:

composer global config bin-dir --absolute --global

# such as $HOME/ poser/vendor/bin, add to $PATH
# save to ~/.zshrc or ~/.bashrc
export PATH=$HOME/ poser/vendor/bin:$PATH

Usage

1. Custom package namespace (Optional)

runp custom

config/packagit.phpfile would be created, you could customize namespace by edit this file, skip here if you don't need custom.

2. Create a new module

runpackagit new ModuleName

you also could group many modules asComponentsor others you want.

packagit new Components/NetUtil
packagit new Components/Updater
packagit new Components/Downloader

A Module Structure:

├── README.md
├── composer.json
├── config
│ └── config.php
├── database
│ ├── factories
│ ├── migrations
│ └── seeders
│ └── DatabaseSeeder.php
├── package.json
├── resources
├── routes
│ ├── api.php
│ └── web.php
├── src
│ ├── Models
│ └── Providers
│ ├── CommandServiceProvider.php
│ ├── RouteServiceProvider.php
│ └── ServiceProvider.php
├── tests
│ ├── Feature
│ └── Unit
└── webpack.mix.js

Load modules in project

1, composer requirewikimedia/composer-merge-plugin

edit project/composer.json => extra => merge-plugins:

"extra": {
"merge-plugin": {
"include": [
"modules/*/composer.json",
"modules/Components/*/composer.json"
],
"recurse": false,
"replace": true,
"ignore-duplicates": false,
"merge-dev": true,
"merge-extra": true,
"merge-extra-deep": true
},
"laravel": {
"dont-discover": []
}
},

2, composer dump-autoload

3, edit project/config/app.php

'providers' => [
\Packagit\[MoudleName]\Providers\ServiceProvider::class,
],

All done, modules should work well.

License

The Apache License 2. Please seeLicense Filefor more information.