Skip to content

Commit

Permalink
Merge pull request #9 from weierophinney/feature/laminas-cli
Browse files Browse the repository at this point in the history
Convert to laminas-cli commands
  • Loading branch information
weierophinney authored Mar 29, 2021
2 parents dcb6de0 + 9518e98 commit 4cc2a1a
Show file tree
Hide file tree
Showing 45 changed files with 4,246 additions and 4,268 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.phpunit.result.cache
/.psalm-cache/
/clover.xml
/config/
/coveralls-upload.json
/phpunit.xml
/vendor/
66 changes: 21 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@ laminas-composer-autoloading
Introduction
------------

The `laminas-composer-autoloading` package provides a single vendor binary,
`laminas-composer-autoloading`, which provides following commands:
The `laminas-composer-autoloading` package provides the following commands for use with [laminas-cli](https://docs.laminas.dev/laminas-cli/):

- `enable` - add the named module to the project autoloading rules
defined in `composer.json`, and
- `disable` - remove autoloading rules for the module from
`composer.json`
- `composer:autoload:enable` - add the named module to the project autoloading rules defined in `composer.json`
- `composer:autoload:disable` - remove autoloading rules for the module from `composer.json`

Both commands also dump the autoloading rules on completion.

> ### Upgrading
>
> If you were using the v1 series of this component, the script previously
> exposed was `autoload-module-via-composer`. That script is now renamed
> to `laminas-composer-autoloading`.
> If you were using the v2 series of this component, the package previously provided its own binary, `laminas-composer-autoloading`.
> You will now call `laminas composer:autoload:(disable|enable)` instead.
Installation
------------
Expand All @@ -37,41 +33,21 @@ Usage
-----

```bash
$ ./vendor/bin/laminas-composer-autoloading \
> enable|disable \
> [help|--help|-h] \
> [--composer|-c <composer path>] \
> [--type|-t <psr0|psr4>] \
> [--modules-path|-p <path>] \
> modulename
# Enable the module "Foo" and autodetermine if PSR-0 or PSR-4 autoloading should be generated
$ ./vendor/bin/laminas composer:autoload:enable Foo
# Enable the module "Bar" using PSR-0 rules
$ ./vendor/bin/laminas composer:autoload:enable Bar --type psr-0
# Disable the module "Baz"
$ ./vendor/bin/laminas composer:autoload:disable Baz
```

### Commands

- `enable` - enables composer-based autoloading for the module.
- `disable` - disables composer-based autoloading for the module.

### Arguments

- `help`, `--help`, and `-h` each display the script's help message.
- `--composer` and `-c` each allow you to specify the path to the Composer
binary, if it is not in your `$PATH`.
- `--type` and `-t` allow you to specify the autoloading type, which should be
one of `psr-0` or `psr-4`; if not provided, the script will attempt to
auto-determine the value based on the directory structure of the module.
- `--modules-path` and `-p` allow you to specify the path to the modules
directory; default to `module`.
- `modulename` is the name of the module for which to setup Composer-based
autoloading.
Use `laminas help <command>` to get detailed help about available options and arguments.

### Notes

- Modules are assumed to have a `src/` directory. If they do not, the
autoloading generated will be incorrect.
- If unable to determine the autoloading type, PSR-0 will be assumed.
- On enabling autoloading, if the `Module` class file for the module
is in the module root, it will be moved to the module's `src/` directory
(laminas-mvc applications only).
- Modules are assumed to have a `src/` directory. If they do not, the autoloading generated will be incorrect.
- If unable to determine the autoloading type, the command raises an exception.
- On enabling autoloading, if the `Module` class file for the module is in the module root, it will be moved to the module's `src/` directory (laminas-mvc applications only).

Examples
--------
Expand All @@ -80,40 +56,40 @@ Examples
entry for "Status" module.

```bash
$ ./vendor/bin/laminas-composer-autoloading enable Status
$ ./vendor/bin/laminas composer:autoload:enable Status
```

1. Autodetect a module's autoloading type, and remove a Composer autoloading
entry for "Status" module.

```bash
$ ./vendor/bin/laminas-composer-autoloading disable Status
$ ./vendor/bin/laminas composer:autoload:disable Status
```

1. Specify PSR-0 for the module type, and generate a Composer autoloading
entry for "Status" module.

```bash
$ ./vendor/bin/laminas-composer-autoloading enable --type psr0 Status
$ ./vendor/bin/laminas composer:autoload:enable --type psr-0 Status
```

1. Specify PSR-4 for the module type, and generate a Composer autoloading
entry for "Status" module.

```bash
$ ./vendor/bin/laminas-composer-autoloading enable --type psr4 Status
$ ./vendor/bin/laminas composer:autoload:enable --type psr-4 Status
```

1. Specify the path to the composer binary when generating autoloading entry
for "Status" module:

```bash
$ ./vendor/bin/laminas-composer-autoloading enable -c composer.phar Status
$ ./vendor/bin/laminas composer:autoload:enable -c composer.phar Status
```

1. Specify the path to modules directory, and generate a Composer autoloading
entry for "Status" module.

```bash
$ ./vendor/bin/laminas-composer-autoloading enable -p src Status
$ ./vendor/bin/laminas composer:autoload:enable -m src Status
```
26 changes: 0 additions & 26 deletions bin/laminas-composer-autoloading

This file was deleted.

17 changes: 6 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@
"sort-packages": true
},
"extra": {
"laminas": {
"component": "Laminas\\ComposerAutoloading",
"config-provider": "Laminas\\ComposerAutoloading\\ConfigProvider"
}
},
"require": {
"php": "^7.3 || ~8.0.0",
"laminas/laminas-stdlib": "^3.1",
"laminas/laminas-zendframework-bridge": "^1.0"
"laminas/laminas-cli": "^1.0",
"webmozart/assert": "^1.10"
},
"require-dev": {
"laminas/laminas-coding-standard": "~2.1.4",
"mikey179/vfsstream": "^1.6.7",
"mockery/mockery": "^1.4.1",
"php-mock/php-mock-phpunit": "^2.0",
"phpunit/phpunit": "^9.3",
"psalm/plugin-mockery": "^0.7.0",
"psalm/plugin-phpunit": "^0.15.1",
"vimeo/psalm": "^4.6"
},
Expand All @@ -46,9 +47,6 @@
"LaminasTest\\ComposerAutoloading\\": "test/"
}
},
"bin": [
"bin/laminas-composer-autoloading"
],
"scripts": {
"check": [
"@cs-check",
Expand All @@ -58,8 +56,5 @@
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
},
"replace": {
"zfcampus/zf-composer-autoloading": "^2.1.0"
}
}
Loading

0 comments on commit 4cc2a1a

Please sign in to comment.