Skip to content

Commit

Permalink
Composer 2 support (#47)
Browse files Browse the repository at this point in the history
- stop testing on PHP5
- raise PHPUnit to "^8" (support for PHP 7.1-7.4)
- migrate to PHPUnit 6+ (\PHPUnit\Framework\TestCase + setUp():void)

- updated Changelog + Readme section on how to require a specific phantomjs version
  • Loading branch information
jakoch committed Jul 18, 2020
1 parent 3891cb6 commit 1f2df4a
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 121 deletions.
49 changes: 49 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM php:7.4-cli

ENV DEBIAN_FRONTEND=noninteractive

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
&& apt-get -y install git openssh-client less iproute2 procps lsb-release unzip \
&& apt-get -y install libfontconfig1 libbz2-dev libzip-dev \
#
# Xdebug
&& yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
#
# Create a non-root user to use if preferred
&& groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
# [Optional] Add sudo support for the non-root user
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
#
# Install Composer v1, then self-update to snapshot of v2
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& composer self-update --snapshot \
&& composer --version

# For PhantomJS
ENV OPENSSL_CONF=/etc/ssl/

# Install bz2, requires libbz2-dev
RUN docker-php-ext-install bz2

# Install zip, requires libzip-dev zlib1g-dev
RUN docker-php-ext-configure zip
RUN docker-php-ext-install zip

ENV DEBIAN_FRONTEND=dialog
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "PHP 7 + Composer + phantomjs-installer",
"dockerFile": "Dockerfile",

// Use 'settings' to set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"felixfbecker.php-debug",
"felixfbecker.php-intellisense",
//"shd101wyy.markdown-preview-enhanced",
//"auchenberg.vscode-browser-preview",
//"whatwedo.twig",
//"mtxr.sqltools"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "php -v",

// Comment out if you want to use root
"remoteUser": "vscode"

}
31 changes: 13 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# .travis.yml - configuration file for the travis continuous integration service
#
# see http://about.travis-ci.org/docs/user/languages/php for more hints
# see https://docs.travis-ci.com/user/languages/php/ for more hints
#
language: php

Expand All @@ -12,35 +12,30 @@ cache:
directory:
- $HOME/.composer/cache/files

php: [5.5, 5.6, 7.1, 7.2]
php: [7.2, 7.4]

before_install:
- composer self-update
- composer install --no-interaction --prefer-source

script:
- phpunit --configuration ./tests/phpunit.xml.dist
- vendor/bin/phpunit --configuration ./tests/phpunit.xml.dist
# tests
# require "1.9.8"
#- cd "$TRAVIS_BUILD_DIR/tests/example-v1.9.8" && composer install -vvv --profile
#- ls -ashF bin
#- bin/phantomjs -v
#- cd $TRAVIS_BUILD_DIR
# require "dev-master"
# Using Composer v1
# require "dev-master" -> v2.1.1 (hardcoded fallback)
- cd "$TRAVIS_BUILD_DIR/tests/example-latest-version" && composer install -vvv --profile
- ls -ashF bin
- bin/phantomjs -v
# require "2.0.0" and lower version automatically to "1.9.8"
- cd "$TRAVIS_BUILD_DIR/tests/example-v2.0.0-v1.9.8" && composer install -vvv --profile
# Using Composer 2.0-dev snapshot
- composer self-update --snapshot
- composer --version
# require "dev-master" -> v2.1.1 (composer.json's extra section)
- cd "$TRAVIS_BUILD_DIR/tests/example-extra-version" && composer install -vvv --profile
- ls -ashF bin
- bin/phantomjs -v

notifications:
email: false
irc:
channels:
- "irc.freenode.org#koch"
use_notice: true
# Reminder:
# if you define version "2.0.0" in composer.json's extra section,
# it should fetch v1.9.8 via retry/auto-lowering.

# reduce commit history of git checkout
git:
Expand Down
21 changes: 17 additions & 4 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@

- "It was a bright day in April, and the clocks were striking thirteen." - 1984

## [3.0.0] - 2020-07-18

- [Issue #47](https://github.com/jakoch/phantomjs-installer/issues/47): Composer v2 support
- Removed direct mapping of package version to PhantomJS version (!)
- The search order for the PhantomJS version changed to:
1. $_ENV['PHANTOMJS_VERSION']
2. $_SERVER['PHANTOMJS_VERSION']
3. composer.json extra section, e.g. `"extra": { "jakoch/phantomjs-installer": { "phantomjs-version": "2.1.1" } }`
4. fallback to v2.1.1 (hardcoded latest version)
- raise PHPUnit version to ^8 (for PHP 7.2-7.4)
- Travis: stopped testing on PHP 5.x & 7.1, added testing PHP 7.4

## [2.1.1-p09] - 2017-08-16

- [Issue #18](https://github.com/jakoch/phantomjs-installer/issues/18): Stop/kill (and restart?) PhantomJS before updating it.
- Fixed replacing the binary of a running process by copying the binary to a temporary file, then renaming it.
- [Issue #41](https://github.com/jakoch/phantomjs-installer/issues/41): 0770 chmod status.
- removed const PHANTOMJS_CHMOD and hardcoded `0777 & ~umask()`
- removed const PHANTOMJS_CHMOD and hardcoded `0777 & ~umask()`
- Travis: stopped testing on HHVM, added testing on PHP7.1

## [2.1.1-p08] - 2017-01-10
Expand All @@ -25,7 +37,7 @@

## [2.1.1-p06] - 2016-08-09

- [Issue #34](https://github.com/jakoch/phantomjs-installer/issues/34): Bitbucket downloading issue
- [Issue #34](https://github.com/jakoch/phantomjs-installer/issues/34): Bitbucket downloading issue
- added env and server variable `PHANTOMJS_CDNURL` to set a mirror as download location
- added `$_SERVER` variable handling for all `$_ENV` vars
this enables you to use either a server or env var for `PHANTOMJS_PLATFORM`, `PHANTOMJS_BITSIZE` and `PHANTOMJS_CDNURL`
Expand All @@ -48,7 +60,7 @@

## [2.1.1-p02] - 2016-05-12

- [Fix #29](https://github.com/jakoch/phantomjs-installer/issues/29): Invalid version string "^2.1"
- [Fix #29](https://github.com/jakoch/phantomjs-installer/issues/29): Invalid version string "^2.1"

## [2.1.1-p01] - 2016-04-12

Expand All @@ -74,7 +86,8 @@
- Initial Release
- grab version number from explicit commit references, issue #8

[Unreleased]: https://github.com/jakoch/phantomjs-installer/compare/2.1.1-p09...HEAD
[Unreleased]: https://github.com/jakoch/phantomjs-installer/compare/3.0.0...HEAD
[3.0.0]: https://github.com/jakoch/phantomjs-installer/compare/2.1.1-p09...3.0.0
[2.1.1-p09]: https://github.com/jakoch/phantomjs-installer/compare/2.1.1-p08...2.1.1-p09
[2.1.1-p08]: https://github.com/jakoch/phantomjs-installer/compare/2.1.1-p07...2.1.1-p08
[2.1.1-p07]: https://github.com/jakoch/phantomjs-installer/compare/2.1.1-p06...2.1.1-p07
Expand Down
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ phantomjs-installer

A Composer package which installs the PhantomJS binary (Linux, Windows, Mac) into `/bin` of your project.

##### Table of Contents
##### Table of Contents

- [Installation](#installation)
- [How to require a specific version of PhantomJS?](#how-to-require-specific-versions-of-phantomjs)
Expand All @@ -25,7 +25,7 @@ To install PhantomJS as a local, per-project dependency to your project, simply
```json
{
"require": {
"jakoch/phantomjs-installer": "2.1.1-p09"
"jakoch/phantomjs-installer": "^3"
},
"config": {
"bin-dir": "bin"
Expand Down Expand Up @@ -56,21 +56,20 @@ will be installed into the `/bin` folder and updated alongside the project's Com

## How to require specific versions of PhantomJS?

1. The version number of the package specifies the PhantomJS version.
When you specify:
- `2.1.1-p07`: Composer fetches the 2.1.1-p07 tag of the installer. The installer fetches the 2.1.1 version of PhantomJS.
- `2.1.1`: Composer fetches the 2.1.1 tag of the installer. The installer fetches the 2.1.1 version of PhantomJS.
- `1.9.8`: Composer fetches the 1.9.8 tag of the installer. The installer fetches the 1.9.8 version of PhantomJS.
- This will also fetch an old installer tag. Please use the syntax for a version alias instead (see item 3 below).
- **Important! Please use exact versioning, e.g. `2.1.1-p07`. Do not use a wildcard or caret operator, e.g. `^2.1`, as this will not resolve to the latest patch level version.**
2. If you specify `dev-master`, the latest version will be fetched.
- Composer fetches the latest version of the installer. The installer fetches the latest version of PhantomJS.
3. You might also specify the PhantomJS version by using a version alias, e.g. `dev-master as <version>`.
- Composer fetches the latest version of the installer. The installer fetches `<version>` of PhantomJS!
4. If you specify an explicit commit reference with a version alias, e.g. `dev-master#<commit-ref> as <version>`.
- Composer fetches a specific git commit of the installer. The installer fetches `<version>` of PhantomJS!

You find more details on the versioning scheme used by the installer in the [comments of issue 39](https://github.com/jakoch/phantomjs-installer/issues/39).
The environment and server variable `PHANTOMJS_VERSION` enables you specify the version requirement at the time of packaging.

You can also set the `phantomjs-version` in the `extra` section of your `composer.json`:

```json
"extra": {
"jakoch/phantomjs-installer": {
"phantomjs-version": "2.1.1"
}
}
```

The search order for the version is 1) $_ENV, 2) $_SERVER, 3) `composer.json` (extra section), 4) fallback to v2.1.1 (hardcoded latest version).


## How does this work internally?

Expand Down Expand Up @@ -160,9 +159,9 @@ You might use one of the following mirror URLs as a value for `PHANTOMJS_CDNURL`

This list of mirrors is not complete. If you know another mirror, please don't hesitate to add it here.

The mirror URLs are also not hardcoded, except for the Github URL.
The mirror URLs are also not hardcoded, except for the Github URL.
This enables you to point to any PhantomJS mirror or download folder you like.
For instance, you could point to the URL of the download folder of your company, where the binaries are stored:
For instance, you could point to the URL of the download folder of your company, where the binaries are stored:
`PHANTOMJS_CDNURL=https://cdn.company.com/downloads/phantomjs/`.

## Automatic download retrying with version lowering on 404
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"require-dev": {
"composer/composer": "^1.2",
"phpunit/phpunit": "^4.8"
"phpunit/phpunit": "^8"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 1f2df4a

Please sign in to comment.