Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/8'
Browse files Browse the repository at this point in the history
Close #8
  • Loading branch information
weierophinney committed Feb 22, 2017
2 parents b82aaa1 + 41aac9b commit 3643d9d
Show file tree
Hide file tree
Showing 25 changed files with 3,787 additions and 343 deletions.
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage_clover: clover.xml
json_path: coveralls-upload.json
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/test export-ignore
vendor export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
phpcs.xml export-ignore
phpunit.xml.dist export-ignore
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
vendor/
composer.lock
phpunit.xml
clover.xml
coveralls-upload.json
54 changes: 49 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: false

language: php

cache:
directories:
- $HOME/.composer/cache
Expand All @@ -10,27 +10,71 @@ cache:
env:
global:
- COMPOSER_ARGS="--no-interaction"
- COVERAGE_DEPS="satooshi/php-coveralls"
- LEGACY_DEPS="phpunit/phpunit php-mock/php-mock-phpunit"

matrix:
include:
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=locked
- TEST_COVERAGE=true
- php: 5.6
env:
- DEPS=latest
- php: 7
env:
- DEPS=lowest
- php: 7
env:
- DEPS=locked
- CS_CHECK=true
- php: 7
env:
- DEPS=latest
- php: 7.1
env:
- DEPS=lowest
- php: 7.1
env:
- DEPS=locked
- php: 7.1
env:
- DEPS=latest
- php: hhvm
env:
- DEPS=lowest
- php: hhvm
env:
- DEPS=locked
- php: hhvm
env:
- DEPS=latest
allow_failures:
- php: hhvm

notifications:
irc: "irc.freenode.org#apigility-dev"
email: false

before_install:
- phpenv config-rm xdebug.ini || return 0
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- travis_retry composer self-update

install:
- travis_retry composer install $COMPOSER_ARGS
- travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs
- if [[ $TRAVIS_PHP_VERSION =~ ^5.6 ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
- composer show

script:
- composer cs-check
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer upload-coverage ; fi
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.0.0 - 2017-02-22

### Added

- [#8](https://github.com/zfcampus/zf-composer-autoloading/pull/8) extracts the classes
`ZF\ComposerAutoloading\Help`, `ZF\ComposerAutoloading\Command\Enable`, and
`ZF\ComposerAutoloading\Command\Disable` from the `ZF\ComposerAutoloading\Command` class,
which now delegates to each of them to perform its tasks.

### Changes

- [#8](https://github.com/zfcampus/zf-composer-autoloading/pull/8) renames the
script from `autoload-module-via-composer` to `zf-composer-autoloading`.

- [#8](https://github.com/zfcampus/zf-composer-autoloading/pull/8) renames the
`Command::__invoke()` method to `Command::process()`.

- [#8](https://github.com/zfcampus/zf-composer-autoloading/pull/8) adds a dependency
on zend-stdlib in order to facilitate colorized console reporting, and allow
testing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.

## 1.1.1 - 2017-02-22

### Added
Expand Down
63 changes: 45 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
zf-composer-autoloading
=======================

[![Build Status](https://travis-ci.org/zfcampus/zf-composer-autoloading.png)](https://travis-ci.org/zfcampus/zf-composer-autoloading)
[![Build Status](https://travis-ci.org/zfcampus/zf-composer-autoloading.svg?branch=master)](https://travis-ci.org/zfcampus/zf-composer-autoloading)
[![Coverage Status](https://coveralls.io/repos/github/zfcampus/zf-composer-autoloading/badge.svg?branch=master)](https://coveralls.io/github/zfcampus/zf-composer-autoloading?branch=master)

Introduction
------------

The `zf-composer-autoloading` package provides a single vendor binary,
`autoload-module-via-composer`, which will:
`zf-composer-autoloading`, which provides following commands:

- Add the named module to the project autoloading rules defined in
`composer.json`, and
- Dump the autoloading rules on completion.
- `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`

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 `zf-composer-autoloading`.
Installation
------------
Expand All @@ -22,18 +32,26 @@ Run the following `composer` command:
$ composer require --dev "zfcampus/zf-composer-autoloading"
```

Note the `--dev` flag; this tool is intended for use in development only.

Usage
-----

```bash
$ ./vendor/bin/autoload-module-via-composer \
$ ./vendor/bin/zf-composer-autoloading \
> enable|disable \
> [help|--help|-h] \
> [--composer|-c <composer path>] \
> [--type|-t <psr0|psr4>] \
> [--modules-path|-p <path>] \
> modulename
```

### 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.
Expand All @@ -52,42 +70,51 @@ $ ./vendor/bin/autoload-module-via-composer \
- 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.
- If the `Module` class file for the module is in the module root, it will be
moved to the module's `src/` directory.
- 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
(zend-mvc applications only).

Examples
--------

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

```bash
$ ./vendor/bin/autoload-module-via-composer Status
$ ./vendor/bin/zf-composer-autoloading enable Status
```

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

```bash
$ ./vendor/bin/zf-composer-autoloading disable Status
```

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

```bash
$ ./vendor/bin/autoload-module-via-composer --type psr0 Status
$ ./vendor/bin/zf-composer-autoloading enable --type psr0 Status
```

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

```bash
$ ./vendor/bin/autoload-module-via-composer --type psr4 Status
$ ./vendor/bin/zf-composer-autoloading enable --type psr4 Status
```

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

```bash
$ ./vendor/bin/autoload-module-via-composer -c composer.phar Status
$ ./vendor/bin/zf-composer-autoloading enable -c composer.phar Status
```

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

```bash
$ ./vendor/bin/autoload-module-via-composer -p src Status
$ ./vendor/bin/zf-composer-autoloading enable -p src Status
```
33 changes: 0 additions & 33 deletions bin/autoload-module-via-composer

This file was deleted.

26 changes: 26 additions & 0 deletions bin/zf-composer-autoloading
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env php
<?php
/**
* Enable/Disable composer-based autoloading for a Zend Framework module.
*
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
*/

namespace ZF\ComposerAutoloading;

use Zend\Stdlib\ConsoleHelper;

// Setup/verify autoloading
if (file_exists($a = __DIR__ . '/../../../autoload.php')) {
require $a;
} elseif (file_exists($a = __DIR__ . '/../vendor/autoload.php')) {
require $a;
} else {
fwrite(STDERR, 'Cannot locate autoloader; please run "composer install"' . PHP_EOL);
exit(1);
}

$command = new Command($argv[0], new ConsoleHelper());
$return = $command->process(array_slice($argv, 1));
exit($return);
27 changes: 23 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"autoloading",
"console",
"framework",
"zendframework",
"zf2"
"zendframework"
],
"homepage": "http://apigility.org/",
"support": {
Expand All @@ -21,19 +20,39 @@
"dev-master": "2.0-dev"
}
},
"require": {
"php": "^5.6 || ^7.0",
"zendframework/zend-stdlib": "^3.1"
},
"require-dev": {
"mikey179/vfsStream": "^1.6.4",
"mockery/mockery": "^0.9.8",
"php-mock/php-mock-phpunit": "^2.0 || ^1.1.2",
"phpunit/phpunit": "^6.0.7 || ^5.7.14",
"zendframework/zend-coding-standard": "~1.0.0"
},
"autoload": {
"psr-4": {
"ZF\\ComposerAutoloading\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"ZFTest\\ComposerAutoloading\\": "test/"
}
},
"bin": [
"bin/autoload-module-via-composer"
"bin/zf-composer-autoloading"
],
"scripts": {
"check": [
"@cs-check",
"@test"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf"
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --coverage-clover clover.xml",
"upload-coverage": "coveralls -v"
}
}
Loading

0 comments on commit 3643d9d

Please sign in to comment.