Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct module folder name #18

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,17 +2,24 @@

The purpose of this package is to allow for easy installation of standalone Modules into the [Laravel Modules](https://github.com/nWidart/laravel-modules) package. This package will ensure that your module is installed into the `Modules/` directory instead of `vendor/`.

You can specify an alternate directory by including a `module-dir` in the extra data in your composer.json file:
You can specify an alternate directory by including a `module-dir` in the extra data in your app `composer.json` file:

"extra": {
"module-dir": "Custom"
}

Also you can specify exact module name in package `composer.json` before its publication:

"extra": {
"module-name": "blog"
}

Here in example target folder is `Modules/Blog` (`ucfirst` for `module-name` applied).

## Installation

1. Ensure you have the `type` set to `laravel-module` in your module's `composer.json`
2. Ensure your package is named in the convention `<namespace>/<name>-module`, for example `joshbrw/user-module` would install into `Modules/User`
2. (Skip when package's `composer.json` contains `module-name`). Ensure your package is named in the convention `<namespace>/<name>-module`, for example `joshbrw/user-module` would install into `Modules/User`
3. Require this package: `composer require joshbrw/laravel-module-installer`
4. Require your bespoke module using Composer. You may want to set the constraint to `dev-master` to ensure you always get the latest version.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "joshbrw/laravel-module-installer",
"name": "vbulash/laravel-module-installer",
"type": "composer-plugin",
"license": "MIT",
"version": "1.0",
"autoload": {
"psr-4": {
"Joshbrw\\LaravelModuleInstaller\\": "src/"
5 changes: 5 additions & 0 deletions src/LaravelModuleInstaller.php
Original file line number Diff line number Diff line change
@@ -50,6 +50,11 @@ protected function getBaseInstallationPath()
*/
protected function getModuleName(PackageInterface $package)
{
$extra = $package->getExtra();
if ($extra && isset($extra['module-name'])) {
return ucfirst($extra['module-name']);
}

$name = $package->getPrettyName();
$split = explode("/", $name);