Skip to content

Commit c9add02

Browse files
Allow running from composer, as well as phar file
1 parent e7f655a commit c9add02

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

README.md

+23-5
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,41 @@ Calculates the total number of years behind their respective newest versions for
1414

1515
## Requirements
1616

17-
- PHP 7.4 or later
17+
- PHP v7.4 or later
18+
- Composer v2
1819

1920
## Installation
2021

21-
Simply download `libyear.phar` from the latest release.
22+
### Recommended: Composer
2223

23-
Put it in the current directory, or your `$PATH` to be able to reference it from anywhere.
24+
Run `composer global require ecoapm/libyear` and make sure your global composer directory is in your `$PATH`.
25+
26+
Alternatively, `composer require-dev ecoapm/libyear` will add `libyear` as a local dev dependency for your current directory's app.
27+
28+
### Alternative: PHP Archive (PHAR) File
29+
30+
Download `libyear.phar` from the latest release, and put it in the current directory, or somewhere in your `$PATH` to be able to reference it from anywhere.
31+
32+
### Windows Users
33+
34+
Note that PHP for Windows does not include CA certificates, so you'll need to install them if you haven't done so already:
35+
1. Download http://curl.haxx.se/ca/cacert.pem to somewhere permanent (PHP's `extras` directory is a great place)
36+
1. Add `curl.cainfo = "[full path to]\cacert.pem"` to your `php.ini` file
2437

2538
## Usage
26-
`php libyear.phar { path to project } [-q]`
39+
40+
`vendor/bin/libyear { path to project } [-q]`
41+
42+
(or `php path/to/libyear.phar { path to project } [-q]` for the PHAR version)
2743

2844
Arguments:
2945
- `path to project`: required, directory containing `composer.json` and `composer.lock` files
3046
- `-q`: optional, quiet mode will only output libraries which are not up-to-date (that is, where "Libyears Behind" > 0)
3147

3248
## Contributing
3349

34-
When testing new features and bug fixes, you can run the script via `php libyear.php { path } [-q]` before building the `phar` file.
50+
Please be sure to read and follow ecoAPM's [Contribution Guidelines](CONTRIBUTING.md) when submitting issues or pull requests.
51+
52+
When testing new features and bug fixes, you can run the script via `./libyear { path } [-q]` before building the `phar` file.
3553

3654
To build the `phar` file for final manual testing, run `php -dphar.readonly=0 build.php`. You may wish to run `composer install --no-dev` first to speed up the build process by removing dev dependencies, but will need to reinstall them via `composer install` (specifically, `phpunit` and `mockery` for unit testing).

libyear

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use LibYear\Factory;
66

7-
require_once __DIR__ . '/vendor/autoload.php';
7+
const vendor_indicator = 'vendor' . DIRECTORY_SEPARATOR . 'ecoapm' . DIRECTORY_SEPARATOR . 'libyear';
8+
$is_vendored = strpos(__DIR__, vendor_indicator) === strlen(__DIR__) - strlen(vendor_indicator);
9+
require_once __DIR__ . ($is_vendored ? '/../../..' : '') . '/vendor/autoload.php';
810

911
Factory::App()->run($argv);

0 commit comments

Comments
 (0)