Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Jul 6, 2020
1 parent cb79bbc commit a06002f
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ yarn-error.log

npm-debug.log*
.phpunit.result.cache
composer.lock
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ that now:
composer update modules/my-module
```

### Optional: Initialization

You can run the initialization command to make sure that your project is set up
for module support:

```shell script
php artisan module:init
```

This will add a `Modules` test suite to your `phpunit.xml` file (if one exists)
and may, in the future, add other scaffolding as needed. It should be safe to run
this command at any time, as it will only add missing configuration.

### Optional: Customize namespaces & paths

By default, modules will be in the `Modules\` namespace and installed into the
Expand Down Expand Up @@ -128,6 +141,17 @@ expected in most cases:

Most things *just work*.

### Commands

We provide a few helper commands:

- `php artisan make:module` — scaffold a new module
- `php artisan module:cache` — cache the loaded modules for slightly faster auto-discovery
- `php artisan module:clear` — clear the module cache
- `php artisan module:init` — initialize your project for modular
- `php artisan module:list` — list all modules
- `php artisan module:update-phpstorm-config` — update PhpStorm configs for module support

We also add a `--module=` option to most Laravel `make:` commands so that you can
use all the existing tooling that you know. The commands themselves are exactly the
same, which means you can use your [custom stubs](https://laravel.com/docs/7.x/artisan#stub-customization)
Expand Down
44 changes: 44 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "internachi/modular",
"description": "Modularize your Laravel apps",
"keywords": [
"laravel",
"modules",
"modular",
"module"
],
"version": "1.0",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"InterNACHI\\Modular\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"InterNACHI\\Modular\\Tests\\": "tests/"
}
},
"minimum-stability": "stable",
"extra": {
"laravel": {
"providers": [
"InterNACHI\\Modular\\Support\\ModularServiceProvider",
"InterNACHI\\Modular\\Support\\ModularizedCommandsServiceProvider"
],
"aliases": {
"Modules": "InterNACHI\\Modular\\Support\\Facades\\Modules"
}
}
},
"require": {
"php": ">=7.4",
"illuminate/support": "^7.0|^8.0"
},
"require-dev": {
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^8.0",
"mockery/mockery": "^1.3"
}
}
7 changes: 7 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'modules_directory' => 'app-modules',
'modules_namespace' => 'Modules',
'tests_base' => 'Tests\TestCase',
];
39 changes: 39 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace InterNACHI\Modular\Tests;

use InterNACHI\Modular\Support\Facades\Modules;
use InterNACHI\Modular\Support\ModularizedCommandsServiceProvider;
use InterNACHI\Modular\Support\ModularServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;

abstract class TestCase extends Orchestra
{
protected function setUp() : void
{
parent::setUp();

$config = $this->app['config'];

// Add encryption key for HTTP tests
$config->set('app.key', 'base64:tfsezwCu4ZRixRLA/+yL/qoouX++Q3lPAPOAbtnBCG8=');

// Add feature stubs to view
$this->app['view']->addLocation(__DIR__.'/Feature/stubs');
}

protected function getPackageProviders($app)
{
return [
ModularServiceProvider::class,
ModularizedCommandsServiceProvider::class,
];
}

protected function getPackageAliases($app)
{
return [
'Modules' => Modules::class,
];
}
}

0 comments on commit a06002f

Please sign in to comment.