在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):pingpong-labs/modules开源软件地址(OpenSource Url):https://github.com/pingpong-labs/modules开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):Laravel 5 Modules
Upgrade GuideTo 2.0.18If you have been updated to version To 2.0.10Previously, we add two service provider from this package. In version From Laravel 4 to Laravel 5If upgrade your Laravel app from Laravel 4 to Laravel 5, there is a few things to do if you are using this package. You will receive some kind errors about config not loaded. To fix this issue, please follow this instruction.
From 1.1.* to 1.2.0New configuration file. This breaking change affected if you publish the configuration file from this package. To fix this issue, create new config file called InstallationTo install through composer, simply put the following in your composer.json file: {
"require": {
"pingpong/modules": "~2.1"
}
} And then run Quick InstallationYou could also simplify the above code by using the following command:
Add Service ProviderNext add the following service provider in 'providers' => array(
'Pingpong\Modules\ModulesServiceProvider',
), Next, add the following aliases to
Next publish the package's configuration file by run :
AutoloadingBy default controllers, entities or repositories not loaded automatically. You can autoload all that stuff using {
"autoload": {
"psr-4": {
"App\\": "app/",
"Modules\\": "modules/"
}
}
} Configuration
Creating A ModuleTo create a new module you can simply run :
Create a new module
Create multiple modules
By default if you create a new module, that will add some resources like controller, seed class or provider automatically. If you don't want these, you can add php artisan module:make Blog --plain
#OR
php artisan module:make Blog -p Because we are autoloading the modules using
Artisan CommandsCreate new module.
Use the specified module. Please see #26. php artisan module:use blog Show all modules in command line.
Create new command for the specified module.
Create new migration for the specified module.
Rollback, Reset and Refresh The Modules Migrations.
Rollback, Reset and Refresh The Migrations for the specified module.
Create new seed for the specified module.
Migrate from the specified module.
Migrate from all modules.
Seed from the specified module.
Seed from all modules.
Create new controller for the specified module.
Publish assets from the specified module to public directory.
Publish assets from all modules to public directory.
Create new model for the specified module.
Create new service provider for the specified module.
Publish migration for the specified module or for all modules.
This helpful when you want to rollback the migrations. You can also run For the specified module.
For all modules.
Enable the specified module.
Disable the specified module.
Generate new middleware class.
Update dependencies for the specified module.
Update dependencies for all modules.
Show the list of modules.
FacadesGet all modules. Module::all(); Get all cached modules. Module::getCached() Get ordered modules. The modules will be ordered by the Module::getOrdered(); Get scanned modules. Module::scan(); Find a specific module. Module::find('name');
// OR
Module::get('name'); Find a module, if there is one, return the Module::findOrFail('module-name'); Get scanned paths. Module::getScanPaths(); Get all modules as a collection instance. Module::toCollection(); Get modules by the status. 1 for active and 0 for inactive. Module::getByStatus(1); Check the specified module. If it exists, will return Module::has('blog'); Get all enabled modules. Module::enabled(); Get all disabled modules. Module::disabled(); Get count of all modules. Module::count(); Get module path. Module::getPath(); Register the modules. Module::register(); Boot all available modules. Module::boot(); Get all enabled modules as collection instance. Module::collections(); Get module path from the specified module. Module::getModulePath('name'); Get assets path from the specified module. Module::getAssetPath('name'); Get config value from this package. Module::config('composer.vendor'); Get used storage path. Module::getUsedStoragePath(); Get used module for cli session. Module::getUsedNow();
// OR
Module::getUsed(); Set used module for cli session. Module::setUsed('name'); Get modules's assets path. Module::getAssetsPath(); Get asset url from specific module. Module::asset('blog:img/logo.img'); Install the specified module by given module name. Module::install('pingpong-modules/hello'); Update dependencies for the specified module. Module::update('hello'); Module EntityGet an entity from a specific module. $module = Module::find('blog'); Get module name.
Get module name in lowercase.
Get module name in studlycase.
Get module path.
Get extra path.
Disable the specified module.
Enable the specified module.
Delete the specified module.
Custom NamespacesWhen you create a new module it also registers new custom namespace for Calling Lang: Lang::get('blog::group.name'); Calling View: View::make('blog::index')
View::make('blog::partials.sidebar') Calling Config: Config::get('blog.name') Publishing ModulesHave you created a laravel modules? Yes, I've. Then, I want to publish my modules. Where do I publish it? That's the question. What's the answer ? The answer is Packagist. In pingpong/modules version >= 1.2.0, when you generate a module, you will see there is a new file generated called Auto Scan Vendor DirectoryBy default the // file config/modules.php
return [
//...
'scan' => [
'enabled' => true
]
//...
] You can verify the module has been installed using
Publishing ModulesAfter creating a module and you are sure your module module will be used by other developers. You can push your module to github or bitbucket and after that you can submit your module to the packagist website. You can follow this step to publish your module.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论