diff --git a/Commands/ControllerCommand.php b/Commands/ControllerCommand.php
index 1b958f8..4ad68f4 100644
--- a/Commands/ControllerCommand.php
+++ b/Commands/ControllerCommand.php
@@ -53,12 +53,16 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
return (new Stub('/controller.stub', [
- 'MODULENAME' => $module->getStudlyName(),
- 'CONTROLLERNAME' => $this->getControllerName(),
- 'CLASS' => $this->getClass(),
- 'NAMESPACE' => $module->getLowername(),
- 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
- 'CLASS_NAMESPACE' => $this->getClassNamespace($module),
+ 'MODULENAME' => $module->getStudlyName(),
+ 'CONTROLLERNAME' => $this->getControllerName(),
+ 'NAMESPACE' => $module->getStudlyName(),
+ 'CLASS_NAMESPACE' => $this->getClassNamespace($module),
+ 'CLASS' => $this->getClass(),
+ 'LOWER_NAME' => $module->getLowerName(),
+ 'MODULE' => $this->getModuleName(),
+ 'NAME' => $this->getModuleName(),
+ 'STUDLY_NAME' => $module->getStudlyName(),
+ 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}
diff --git a/Commands/GenerateFilterCommand.php b/Commands/GenerateFilterCommand.php
index 0239e51..bc2c990 100644
--- a/Commands/GenerateFilterCommand.php
+++ b/Commands/GenerateFilterCommand.php
@@ -53,8 +53,13 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
return (new Stub('/filter.stub', [
- 'NAMESPACE' => $this->getClassNamespace($module),
- 'CLASS' => $this->getClass(),
+ 'NAMESPACE' => $this->getClassNamespace($module),
+ 'CLASS' => $this->getClass(),
+ 'LOWER_NAME' => $module->getLowerName(),
+ 'MODULE' => $this->getModuleName(),
+ 'NAME' => $this->getFileName(),
+ 'STUDLY_NAME' => $this->getFileName(),
+ 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}
diff --git a/Commands/GenerateProviderCommand.php b/Commands/GenerateProviderCommand.php
index f1fb2d8..a14b6b8 100644
--- a/Commands/GenerateProviderCommand.php
+++ b/Commands/GenerateProviderCommand.php
@@ -68,9 +68,16 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
return (new Stub('/'.$stub.'.stub', [
- 'NAMESPACE' => $this->getClassNamespace($module),
- 'CLASS' => $this->getClass(),
- 'LOWER_NAME' => $module->getLowerName(),
+ 'NAMESPACE' => $this->getClassNamespace($module),
+ 'CLASS' => $this->getClass(),
+ 'LOWER_NAME' => $module->getLowerName(),
+ 'MODULE' => $this->getModuleName(),
+ 'NAME' => $this->getFileName(),
+ 'STUDLY_NAME' => $module->getStudlyName(),
+ 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
+ 'PATH_VIEWS' => $this->laravel['config']->get('modules.paths.generator.views'),
+ 'PATH_LANG' => $this->laravel['config']->get('modules.paths.generator.lang'),
+ 'PATH_CONFIG' => $this->laravel['config']->get('modules.paths.generator.config')
]))->render();
}
diff --git a/Commands/GenerateRouteProviderCommand.php b/Commands/GenerateRouteProviderCommand.php
index 43c47b6..04bc1ba 100644
--- a/Commands/GenerateRouteProviderCommand.php
+++ b/Commands/GenerateRouteProviderCommand.php
@@ -43,10 +43,16 @@ protected function getArguments()
*/
protected function getTemplateContents()
{
+ $module = $this->laravel['modules']->findOrFail($this->getModuleName());
+
return (new Stub('/route-provider.stub', [
- 'MODULE' => $this->getModuleName(),
- 'NAME' => $this->getFileName(),
- 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
+ 'NAMESPACE' => $this->getClassNamespace($module),
+ 'CLASS' => $this->getClass(),
+ 'LOWER_NAME' => $module->getLowerName(),
+ 'MODULE' => $this->getModuleName(),
+ 'NAME' => $this->getFileName(),
+ 'STUDLY_NAME' => $module->getStudlyName(),
+ 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}
diff --git a/Commands/MakeRequestCommand.php b/Commands/MakeRequestCommand.php
index 4da7609..82bec02 100644
--- a/Commands/MakeRequestCommand.php
+++ b/Commands/MakeRequestCommand.php
@@ -53,11 +53,13 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
return (new Stub('/request.stub', [
- 'MODULE' => $this->getModuleName(),
- 'NAME' => $this->getFileName(),
- 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
- 'NAMESPACE' => $this->getClassNamespace($module),
- 'CLASS' => $this->getClass(),
+ 'NAMESPACE' => $this->getClassNamespace($module),
+ 'CLASS' => $this->getClass(),
+ 'LOWER_NAME' => $module->getLowerName(),
+ 'MODULE' => $this->getModuleName(),
+ 'NAME' => $this->getFileName(),
+ 'STUDLY_NAME' => $module->getStudlyName(),
+ 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}
diff --git a/Commands/MigrateResetCommand.php b/Commands/MigrateResetCommand.php
index 88da875..4fe07e7 100644
--- a/Commands/MigrateResetCommand.php
+++ b/Commands/MigrateResetCommand.php
@@ -41,7 +41,7 @@ public function fire()
return;
}
- foreach ($this->laravel['modules']->all() as $module) {
+ foreach (array_reverse($this->laravel['modules']->all()) as $module) {
$this->line('Running for module: '.$module->getName().'');
$this->reset($module);
diff --git a/Commands/MigrateRollbackCommand.php b/Commands/MigrateRollbackCommand.php
index 07a7208..f26bf7e 100644
--- a/Commands/MigrateRollbackCommand.php
+++ b/Commands/MigrateRollbackCommand.php
@@ -41,7 +41,7 @@ public function fire()
return;
}
- foreach ($this->laravel['modules']->all() as $module) {
+ foreach (array_reverse($this->laravel['modules']->all()) as $module) {
$this->line('Running for module: '.$module->getName().'');
$this->rollback($module);
diff --git a/Commands/MigrationCommand.php b/Commands/MigrationCommand.php
index a2904e7..2115b73 100644
--- a/Commands/MigrationCommand.php
+++ b/Commands/MigrationCommand.php
@@ -3,7 +3,6 @@
namespace Pingpong\Modules\Commands;
use Illuminate\Support\Str;
-use Pingpong\Generators\Exceptions\InvalidMigrationNameException;
use Pingpong\Generators\Migrations\NameParser;
use Pingpong\Generators\Migrations\SchemaParser;
use Pingpong\Support\Stub;
@@ -102,7 +101,7 @@ protected function getTemplateContents()
]);
}
- throw new InvalidMigrationNameException();
+ throw new \InvalidArgumentException('Invalid migration name');
}
/**
diff --git a/Commands/ModelCommand.php b/Commands/ModelCommand.php
index 81ed01d..0a9cf14 100644
--- a/Commands/ModelCommand.php
+++ b/Commands/ModelCommand.php
@@ -66,12 +66,14 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
return (new Stub('/model.stub', [
- 'MODULE' => $this->getModuleName(),
- 'NAME' => $this->getModelName(),
- 'FILLABLE' => $this->getFillable(),
- 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
- 'NAMESPACE' => $this->getClassNamespace($module),
- 'CLASS' => $this->getClass(),
+ 'NAME' => $this->getModelName(),
+ 'FILLABLE' => $this->getFillable(),
+ 'NAMESPACE' => $this->getClassNamespace($module),
+ 'CLASS' => $this->getClass(),
+ 'LOWER_NAME' => $module->getLowerName(),
+ 'MODULE' => $this->getModuleName(),
+ 'STUDLY_NAME' => $module->getStudlyName(),
+ 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}
diff --git a/Commands/SeedCommand.php b/Commands/SeedCommand.php
index a2f1168..82ab158 100644
--- a/Commands/SeedCommand.php
+++ b/Commands/SeedCommand.php
@@ -35,20 +35,31 @@ public function fire()
{
$this->module = $this->laravel['modules'];
- $module = Str::studly($this->argument('module')) ?: $this->getModuleName();
+ $name = $this->argument('module');
- if ($module) {
- if ($this->module->has($module)) {
- $this->dbseed($module);
-
- return $this->info("Module [$module] seeded.");
+ if ($name) {
+ if (!$this->module->has(Str::studly($name))) {
+ return $this->error("Module [$name] does not exists.");
}
- return $this->error("Module [$module] does not exists.");
+ $class = $this->getSeederName($name);
+ if (class_exists($class)) {
+ $this->dbseed($name);
+
+ return $this->info("Module [$name] seeded.");
+ } else {
+ return $this->error("Class [$class] does not exists.");
+ }
}
- foreach ($this->module->all() as $name) {
- $this->dbseed($name);
+ foreach ($this->module->getOrdered() as $module) {
+ $name = $module->getName();
+
+ if (class_exists($this->getSeederName($name))) {
+ $this->dbseed($name);
+
+ $this->info("Module [$name] seeded.");
+ }
}
return $this->info('All modules seeded.');
@@ -111,6 +122,7 @@ protected function getOptions()
{
return array(
array('class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder', null),
+ array('all', null, InputOption::VALUE_NONE, 'Whether or not we should seed all modules.'),
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed.'),
);
}
diff --git a/Commands/SeedMakeCommand.php b/Commands/SeedMakeCommand.php
index 83414ae..88bc825 100644
--- a/Commands/SeedMakeCommand.php
+++ b/Commands/SeedMakeCommand.php
@@ -65,6 +65,7 @@ protected function getTemplateContents()
'NAME' => $this->getSeederName(),
'MODULE' => $this->getModuleName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
+
]))->render();
}
diff --git a/Commands/stubs/controller.stub b/Commands/stubs/controller.stub
index 2d2352f..82dc564 100644
--- a/Commands/stubs/controller.stub
+++ b/Commands/stubs/controller.stub
@@ -6,7 +6,7 @@ class $CLASS$ extends Controller {
public function index()
{
- return view('$NAMESPACE$::index');
+ return view('$LOWER_NAME$::index');
}
}
\ No newline at end of file
diff --git a/Commands/stubs/routes.stub b/Commands/stubs/routes.stub
index 7231ccf..e89b280 100644
--- a/Commands/stubs/routes.stub
+++ b/Commands/stubs/routes.stub
@@ -1,6 +1,6 @@
'$LOWER_NAME$', 'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers'], function()
+Route::group(['middleware' => 'web', 'prefix' => '$LOWER_NAME$', 'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers'], function()
{
Route::get('/', '$STUDLY_NAME$Controller@index');
});
\ No newline at end of file
diff --git a/Commands/stubs/scaffold/provider.stub b/Commands/stubs/scaffold/provider.stub
index 83f845a..fa1ca20 100644
--- a/Commands/stubs/scaffold/provider.stub
+++ b/Commands/stubs/scaffold/provider.stub
@@ -13,13 +13,13 @@ class $CLASS$ extends ServiceProvider {
/**
* Boot the application events.
- *
+ *
* @return void
*/
public function boot()
{
- $this->registerConfig();
$this->registerTranslations();
+ $this->registerConfig();
$this->registerViews();
}
@@ -29,46 +29,48 @@ class $CLASS$ extends ServiceProvider {
* @return void
*/
public function register()
- {
+ {
//
}
/**
* Register config.
- *
+ *
* @return void
*/
protected function registerConfig()
{
$this->publishes([
- __DIR__.'/../Config/config.php' => config_path('$LOWER_NAME$.php'),
+ __DIR__.'/../$PATH_CONFIG$/config.php' => config_path('$LOWER_NAME$.php'),
]);
$this->mergeConfigFrom(
- __DIR__.'/../Config/config.php', '$LOWER_NAME$'
+ __DIR__.'/../$PATH_CONFIG$/config.php', '$LOWER_NAME$'
);
}
/**
* Register views.
- *
+ *
* @return void
*/
public function registerViews()
{
- $viewPath = base_path('views/modules/$LOWER_NAME$');
+ $viewPath = base_path('resources/views/modules/$LOWER_NAME$');
- $sourcePath = __DIR__.'/../Resources/views';
+ $sourcePath = __DIR__.'/../$PATH_VIEWS$';
$this->publishes([
$sourcePath => $viewPath
]);
- $this->loadViewsFrom([$viewPath, $sourcePath], '$LOWER_NAME$');
+ $this->loadViewsFrom(array_merge(array_map(function ($path) {
+ return $path . '/modules/$LOWER_NAME$';
+ }, \Config::get('view.paths')), [$sourcePath]), '$LOWER_NAME$');
}
/**
* Register translations.
- *
+ *
* @return void
*/
public function registerTranslations()
@@ -78,7 +80,7 @@ class $CLASS$ extends ServiceProvider {
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, '$LOWER_NAME$');
} else {
- $this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', '$LOWER_NAME$');
+ $this->loadTranslationsFrom(__DIR__ .'/../$PATH_LANG$', '$LOWER_NAME$');
}
}
diff --git a/Commands/stubs/views/index.stub b/Commands/stubs/views/index.stub
index ade7584..589a996 100644
--- a/Commands/stubs/views/index.stub
+++ b/Commands/stubs/views/index.stub
@@ -8,4 +8,4 @@
This view is loaded from module: {!! config('$LOWER_NAME$.name') !!}
-@stop
\ No newline at end of file
+@endsection
diff --git a/Exceptions/FileMissingException.php b/Exceptions/FileMissingException.php
deleted file mode 100644
index a1df395..0000000
--- a/Exceptions/FileMissingException.php
+++ /dev/null
@@ -1,7 +0,0 @@
-getContents(), 1);
+ if (config('modules.cache.enabled') === false) {
+ return json_decode($this->getContents(), 1);
+ }
+
+ return app('cache')->remember($this->getPath(), config('modules.cache.lifetime'), function () {
+ return json_decode($this->getContents(), 1);
+ });
}
/**
diff --git a/Module.php b/Module.php
index 476ec9b..cb9d88a 100644
--- a/Module.php
+++ b/Module.php
@@ -169,9 +169,13 @@ protected function registerTranslation()
*
* @return Json
*/
- public function json()
+ public function json($file = null)
{
- return new Json($this->getPath().'/module.json', $this->app['files']);
+ if (is_null($file)) {
+ $file = 'module.json';
+ }
+
+ return new Json($this->getPath() . '/' . $file, $this->app['files']);
}
/**
@@ -187,6 +191,19 @@ public function get($key, $default = null)
return $this->json()->get($key, $default);
}
+ /**
+ * Get a specific data from composer.json file by given the key.
+ *
+ * @param $key
+ * @param null $default
+ *
+ * @return mixed
+ */
+ public function getComposerAttr($key, $default = null)
+ {
+ return $this->json('composer.json')->get($key, $default);
+ }
+
/**
* Register the module.
*/
diff --git a/ModulesServiceProvider.php b/ModulesServiceProvider.php
index 0763b82..1df90ce 100644
--- a/ModulesServiceProvider.php
+++ b/ModulesServiceProvider.php
@@ -64,7 +64,9 @@ protected function registerNamespaces()
{
$configPath = __DIR__.'/src/config/config.php';
$this->mergeConfigFrom($configPath, 'modules');
- $this->publishes([$configPath => config_path('modules.php')]);
+ $this->publishes([
+ $configPath => config_path('modules.php')
+ ], 'config');
}
/**
@@ -88,7 +90,7 @@ protected function registerHtml()
*/
protected function registerServices()
{
- $this->app->bindShared('modules', function ($app) {
+ $this->app->singleton('modules', function ($app) {
$path = $app['config']->get('modules.paths.modules');
return new Repository($app, $path);
diff --git a/Process/Installer.php b/Process/Installer.php
index bd44145..b007831 100644
--- a/Process/Installer.php
+++ b/Process/Installer.php
@@ -152,6 +152,7 @@ public function getProcess()
{
switch ($this->type) {
case 'github':
+ case 'github-https':
case 'bitbucket':
if ($this->tree) {
$process = $this->installViaSubtree();
@@ -194,6 +195,10 @@ public function getRepoUrl()
return "git@github.com:{$this->name}.git";
break;
+ case 'github-https':
+ return "https://github.com/{$this->name}.git";
+ break;
+
case 'bitbucket':
return "git@bitbucket.org:{$this->name}.git";
break;
@@ -248,10 +253,11 @@ public function getPackageName()
public function installViaGit()
{
return new Process(sprintf(
- 'cd %s && git clone %s %s && git checkout %s',
+ 'cd %s && git clone %s %s && cd %s && git checkout %s',
base_path(),
$this->getRepoUrl(),
$this->getDestinationPath(),
+ $this->getDestinationPath(),
$this->getBranch()
));
}
diff --git a/Process/Updater.php b/Process/Updater.php
index 5ba314d..1e8f290 100644
--- a/Process/Updater.php
+++ b/Process/Updater.php
@@ -13,7 +13,7 @@ public function update($module)
{
$module = $this->module->findOrFail($module);
- $packages = $module->get('require', []);
+ $packages = $module->getComposerAttr('require', []);
chdir(base_path());
diff --git a/README.md b/README.md
index eb00da5..70e34ef 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,612 @@
Laravel 5 Modules
-==============
+===============
-Official documentation is located [here](http://sky.pingpong-labs.com/docs/2.0/modules)
\ No newline at end of file
+- [Upgrade Guide](#upgrade-guide)
+- [Installation](#installation)
+- [Configuration](#configuration)
+- [Naming Convension](#naming-convension)
+- [Folder Structure](#folder-structure)
+- [Creating Module](#creating-a-module)
+- [Artisan Commands](#artisan-commands)
+- [Facades](#facades)
+- [Entity](#entity)
+- [Auto Scan Vendor Directory](#auto-scan-vendor-directory)
+- [Publishing Modules](#publishing-modules)
+
+`pingpong/modules` is a laravel package which created to manage your large laravel app using modules. Module is like a laravel package, it have some views, controllers or models. This package is supported and tested in both Laravel 4 and Laravel 5.
+
+
+## Upgrade Guide
+
+#### To 2.0.18
+
+If you have been updated to version `2.0.18`, please read [this release note](https://github.com/pingpong-labs/modules/releases/tag/2.0.18).
+
+#### To 2.0.10
+
+Previously, we add two service provider from this package. In version `2.0.5`, we just need register one service provider. Now, we can remove `Pingpong\Modules\Providers\BootstrapServiceProvider` from `providers` array, because now it service provider is registered automatically by `Pingpong\Modules\ModulesServiceProvider`.
+
+#### From Laravel 4 to Laravel 5
+
+If 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.
+
+- If you publish the package's configuration file, you need to move the config file from `app/config/packages/pingpong/modules/config.php` to `app/config/modules.php`.
+- If you are not publish the package's configuration file and you want to publish the config file, just run `php artisan vendor:publish` command and you are done.
+
+#### From 1.1.* to 1.2.0
+
+New configuration file. This breaking change affected if you publish the configuration file from this package. To fix this issue, create new config file called `config.php` in your `app/config/packages/pingpong/modules/` directory. Next move the array contents from `paths.php` file to `paths` array in new configuration file.
+Your config file will looks like [this](https://github.com/pingpong-labs/modules/blob/1.2.0/src/config/config.php).
+
+
+## Installation
+
+To install through composer, simply put the following in your composer.json file:
+
+```json
+{
+ "require": {
+ "pingpong/modules": "~2.1"
+ }
+}
+```
+
+And then run `composer install` to fetch the package.
+
+#### Quick Installation
+
+You could also simplify the above code by using the following command:
+
+```
+composer require "pingpong/modules:~2.1"
+```
+
+#### Add Service Provider
+
+Next add the following service provider in `config/app.php`.
+
+```php
+'providers' => array(
+ 'Pingpong\Modules\ModulesServiceProvider',
+),
+```
+
+Next, add the following aliases to `aliases` array in the same file.
+
+```
+'aliases' => array(
+ 'Module' => 'Pingpong\Modules\Facades\Module',
+),
+
+```
+
+Next publish the package's configuration file by run :
+
+```
+php artisan vendor:publish
+```
+
+#### Autoloading
+
+By default controllers, entities or repositories not loaded automatically. You can autoload all that stuff using `psr-4`. For example :
+
+```json
+{
+ "autoload": {
+ "psr-4": {
+ "App\\": "app/",
+ "Modules\\": "modules/"
+ }
+ }
+}
+```
+
+
+## Configuration
+
+- `modules` - Used for save the generated modules.
+- `assets` - Used for save the modules's assets from each modules.
+- `migration` - Used for save the modules's migrations if you publish the modules's migrations.
+- `generator` - Used for generate modules folders.
+- `scan` - Used for allow to scan other folders.
+- `enabled` - If `true`, the package will scan other paths. By default the value is `false`
+- `paths` - The list of path which can scanned automatically by the package.
+- `composer`
+ - `vendor` - Composer vendor name.
+ - `author.name` - Composer author name.
+ - `author.email` - Composer author email.
+- `cache`
+ - `enabled` - If `true`, the scanned modules (all modules) will cached automatically. By default the value is `false`
+ - `key` - The name of cache.
+ - `lifetime` - Lifetime of cache.
+
+
+## Creating A Module
+
+To create a new module you can simply run :
+
+```
+php artisan module:make
+```
+
+- `` - Required. The name of module will be created.
+
+**Create a new module**
+
+```
+php artisan module:make Blog
+```
+
+**Create multiple modules**
+
+```
+php artisan module:make Blog User Auth
+```
+
+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 `--plain` flag, to generate a plain module.
+
+```shell
+php artisan module:make Blog --plain
+#OR
+php artisan module:make Blog -p
+```
+
+
+**Naming Convension**
+
+Because we are autoloading the modules using `psr-4`, we strongly recommend using `StudlyCase` convension.
+
+
+**Folder Structure**
+
+```
+laravel-app/
+app/
+bootstrap/
+vendor/
+modules/
+ ├── Blog/
+ ├── Assets/
+ ├── Config/
+ ├── Console/
+ ├── Database/
+ ├── Migrations/
+ ├── Seeders/
+ ├── Entities/
+ ├── Http/
+ ├── Controllers/
+ ├── Middleware/
+ ├── Requests/
+ ├── routes.php
+ ├── Providers/
+ ├── BlogServiceProvider.php
+ ├── Resources/
+ ├── lang/
+ ├── views/
+ ├── Repositories/
+ ├── Tests/
+ ├── composer.json
+ ├── module.json
+ ├── start.php
+```
+
+
+## Artisan Commands
+
+Create new module.
+
+```
+php artisan module:make blog
+```
+
+Use the specified module. Please see [#26](https://github.com/pingpong-labs/modules/pull/26).
+
+```php
+php artisan module:use blog
+```
+
+Show all modules in command line.
+
+```
+php artisan module:list
+```
+
+Create new command for the specified module.
+
+```
+php artisan module:make-command CustomCommand blog
+
+php artisan module:make-command CustomCommand --command=custom:command blog
+
+php artisan module:make-command CustomCommand --namespace=Modules\Blog\Commands blog
+```
+
+Create new migration for the specified module.
+
+```
+php artisan module:make-migration create_users_table blog
+
+php artisan module:make-migration create_users_table --fields="username:string, password:string" blog
+
+php artisan module:make-migration add_email_to_users_table --fields="email:string:unique" blog
+
+php artisan module:make-migration remove_email_from_users_table --fields="email:string:unique" blog
+
+php artisan module:make-migration drop_users_table blog
+```
+
+Rollback, Reset and Refresh The Modules Migrations.
+```
+php artisan module:migrate-rollback
+
+php artisan module:migrate-reset
+
+php artisan module:migrate-refresh
+```
+
+Rollback, Reset and Refresh The Migrations for the specified module.
+```
+php artisan module:migrate-rollback blog
+
+php artisan module:migrate-reset blog
+
+php artisan module:migrate-refresh blog
+```
+
+Create new seed for the specified module.
+
+```
+php artisan module:make-seed users blog
+```
+
+Migrate from the specified module.
+
+```
+php artisan module:migrate blog
+```
+
+Migrate from all modules.
+
+```
+php artisan module:migrate
+```
+
+Seed from the specified module.
+
+```
+php artisan module:seed blog
+```
+
+Seed from all modules.
+
+```
+php artisan module:seed
+```
+
+Create new controller for the specified module.
+
+```
+php artisan module:make-controller SiteController blog
+```
+
+Publish assets from the specified module to public directory.
+
+```
+php artisan module:publish blog
+```
+
+Publish assets from all modules to public directory.
+
+```
+php artisan module:publish
+```
+
+Create new model for the specified module.
+
+```
+php artisan module:make-model User blog
+
+php artisan module:make-model User blog --fillable="username,email,password"
+```
+
+Create new service provider for the specified module.
+
+```
+php artisan module:make-provider MyServiceProvider blog
+```
+
+Publish migration for the specified module or for all modules.
+This helpful when you want to rollback the migrations. You can also run `php artisan migrate` instead of `php artisan module:migrate` command for migrate the migrations.
+
+For the specified module.
+```
+php artisan module:publish-migration blog
+```
+
+For all modules.
+```
+php artisan module:publish-migration
+```
+
+Enable the specified module.
+
+```
+php artisan module:enable blog
+```
+
+Disable the specified module.
+
+```
+php artisan module:disable blog
+```
+
+Generate new middleware class.
+```
+php artisan module:make-middleware Auth
+```
+
+Update dependencies for the specified module.
+```
+php artisan module:update ModuleName
+```
+
+Update dependencies for all modules.
+```
+php artisan module:update
+```
+
+Show the list of modules.
+```
+php artisan module:list
+```
+
+
+## Facades
+
+Get all modules.
+```php
+Module::all();
+```
+
+Get all cached modules.
+```php
+Module::getCached()
+```
+
+Get ordered modules. The modules will be ordered by the `priority` key in `module.json` file.
+```php
+Module::getOrdered();
+```
+
+Get scanned modules.
+```php
+Module::scan();
+```
+
+Find a specific module.
+```php
+Module::find('name');
+// OR
+Module::get('name');
+```
+
+Find a module, if there is one, return the `Module` instance, otherwise throw `Pingpong\Modules\Exeptions\ModuleNotFoundException`.
+```php
+Module::findOrFail('module-name');
+```
+
+Get scanned paths.
+```php
+Module::getScanPaths();
+```
+
+Get all modules as a collection instance.
+```php
+Module::toCollection();
+```
+
+Get modules by the status. 1 for active and 0 for inactive.
+```php
+Module::getByStatus(1);
+```
+
+Check the specified module. If it exists, will return `true`, otherwise `false`.
+```php
+Module::has('blog');
+```
+
+Get all enabled modules.
+```php
+Module::enabled();
+```
+
+Get all disabled modules.
+```php
+Module::disabled();
+```
+
+Get count of all modules.
+```php
+Module::count();
+```
+
+Get module path.
+```php
+Module::getPath();
+```
+
+Register the modules.
+```php
+Module::register();
+```
+
+Boot all available modules.
+```php
+Module::boot();
+```
+
+Get all enabled modules as collection instance.
+```php
+Module::collections();
+```
+
+Get module path from the specified module.
+```php
+Module::getModulePath('name');
+```
+
+Get assets path from the specified module.
+```php
+Module::getAssetPath('name');
+```
+
+Get config value from this package.
+```php
+Module::config('composer.vendor');
+```
+
+Get used storage path.
+```php
+Module::getUsedStoragePath();
+```
+
+Get used module for cli session.
+```php
+Module::getUsedNow();
+// OR
+Module::getUsed();
+```
+
+Set used module for cli session.
+```php
+Module::setUsed('name');
+```
+
+Get modules's assets path.
+```php
+Module::getAssetsPath();
+```
+
+Get asset url from specific module.
+```php
+Module::asset('blog:img/logo.img');
+```
+
+Install the specified module by given module name.
+```php
+Module::install('pingpong-modules/hello');
+```
+
+Update dependencies for the specified module.
+```php
+Module::update('hello');
+```
+
+
+## Module Entity
+
+Get an entity from a specific module.
+
+```php
+$module = Module::find('blog');
+```
+
+Get module name.
+```
+$module->getName();
+```
+
+Get module name in lowercase.
+```
+$module->getLowerName();
+```
+
+Get module name in studlycase.
+```
+$module->getStudlyName();
+```
+
+Get module path.
+```
+$module->getPath();
+```
+
+Get extra path.
+```
+$module->getExtraPath('Assets');
+```
+
+Disable the specified module.
+```
+$module->enable();
+```
+
+Enable the specified module.
+```
+$module->disable();
+```
+
+Delete the specified module.
+```
+$module->delete();
+```
+
+
+## Custom Namespaces
+When you create a new module it also registers new custom namespace for `Lang`, `View` and `Config`. For example, if you create a new module named blog, it will also register new namespace/hint blog for that module. Then, you can use that namespace for calling `Lang`, `View` or `Config`. Following are some examples of its usage:
+
+Calling Lang:
+```php
+Lang::get('blog::group.name');
+```
+
+Calling View:
+```php
+View::make('blog::index')
+
+View::make('blog::partials.sidebar')
+```
+
+Calling Config:
+```php
+Config::get('blog.name')
+```
+
+## Publishing Modules
+
+Have 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](http://packagist.org). In pingpong/modules version >= 1.2.0, when you generate a module, you will see there is a new file generated called `composer.json`.
+
+
+### Auto Scan Vendor Directory
+
+By default the `vendor` directory is not scanned automatically, you need to update the configuration file to allow that. Set `scan.enabled` value to `true`. For example :
+
+```php
+// file config/modules.php
+
+return [
+ //...
+ 'scan' => [
+ 'enabled' => true
+ ]
+ //...
+]
+```
+
+You can verify the module has been installed using `module:list` command:
+
+```
+php artisan module:list
+```
+
+
+## Publishing Modules
+
+After creating a module and you are sure your module module will be used by other developers. You can push your module to [github](https://github.com) or [bitbucket](https://bitbucket.org) and after that you can submit your module to the packagist website.
+
+You can follow this step to publish your module.
+
+1. Create A Module.
+2. Push the module to github.
+3. Submit your module to the packagist website.
+Submit to packagist is very easy, just give your github repository, click submit and you done.
diff --git a/Repository.php b/Repository.php
index c3f69de..0302287 100644
--- a/Repository.php
+++ b/Repository.php
@@ -160,7 +160,9 @@ protected function formatCached($cached)
foreach ($cached as $name => $module) {
$path = $this->config('paths.modules').'/'.$name;
- $modules[] = new Module($this->app, $name, $path);
+ $lowerName = strtolower($name);
+
+ $modules[$name] = new Module($this->app, $lowerName, $path);
}
return $modules;
diff --git a/Routing/Controller.php b/Routing/Controller.php
index 9283498..c0742c8 100644
--- a/Routing/Controller.php
+++ b/Routing/Controller.php
@@ -2,11 +2,12 @@
namespace Pingpong\Modules\Routing;
-use Illuminate\Foundation\Bus\DispatchesCommands;
+use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
-abstract class Controller extends BaseController
+class Controller extends BaseController
{
- use DispatchesCommands, ValidatesRequests;
+ use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
diff --git a/composer.json b/composer.json
index e5db21f..b76beaa 100644
--- a/composer.json
+++ b/composer.json
@@ -17,9 +17,9 @@
],
"require": {
"php": ">=5.4.0",
- "laravel/framework": "5.0.*",
- "pingpong/generators": "~2.0",
- "pingpong/support": "~2.0",
+ "laravel/framework": "5.3.*",
+ "pingpong/generators": "2.2.*",
+ "pingpong/support": "dev-master",
"laravelcollective/html": "~5.0"
},
"require-dev": {