diff --git a/.gitattributes b/.gitattributes index 982c460d..21be40ca 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,6 @@ /.gitattributes export-ignore +/.github/ export-ignore /.gitignore export-ignore -/.travis.yml export-ignore /phpunit.xml.dist export-ignore -/tests export-ignore +/phpunit.xml.legacy export-ignore +/tests/ export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..85aad9c5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,58 @@ +name: CI + +on: + push: + pull_request: + +jobs: + PHPUnit: + name: PHPUnit (PHP ${{ matrix.php }}) + runs-on: ubuntu-22.04 + strategy: + matrix: + php: + - 8.3 + - 8.2 + - 8.1 + - 8.0 + - 7.4 + - 7.3 + - 7.2 + - 7.1 + - 7.0 + - 5.6 + - 5.5 + - 5.4 + - 5.3 + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: xdebug + ini-file: development + ini-values: disable_functions='' # do not disable PCNTL functions on PHP < 8.1 + extensions: sockets, pcntl + env: + fail-fast: true # fail step if any extension can not be installed + - run: composer install + - run: vendor/bin/phpunit --coverage-text --exclude-group internet + if: ${{ matrix.php >= 7.3 }} + - run: vendor/bin/phpunit --coverage-text --exclude-group internet -c phpunit.xml.legacy + if: ${{ matrix.php < 7.3 }} + + PHPUnit-hhvm: + name: PHPUnit (HHVM) + runs-on: ubuntu-22.04 + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM + - name: Run hhvm composer.phar require --dev react/async:^2 react/promise:^2 phpunit/phpunit:^5.7 # downgrade Async and Promise for HHVM + uses: docker://hhvm/hhvm:3.30-lts-latest + with: + args: hhvm composer.phar require --dev react/async:^2 react/promise:^2 phpunit/phpunit:^5.7 + - name: Run hhvm vendor/bin/phpunit --exclude-group internet + uses: docker://hhvm/hhvm:3.30-lts-latest + with: + args: hhvm vendor/bin/phpunit --exclude-group internet diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 79683903..00000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: php - -php: -# - 5.3 # requires old distro, see below - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - hhvm - -# lock distro so new future defaults will not break the build -dist: trusty - -matrix: - include: - - php: 5.3 - dist: precise - allow_failures: - - php: hhvm - -install: - - composer install --no-interaction - -script: - - php vendor/bin/phpunit --coverage-text --exclude-group internet diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f64ba9f..f5f711e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,54 @@ # Changelog +## 1.4.0 (2023-07-11) + +A major new feature release, see [**release announcement**](https://clue.engineering/2023/announcing-reactphp-promise-v3). + +* Feature: Add support for new Promise v3 release. + (#464 and #524 by @clue) + +* Feature: Support PHP 8.2 release. + (#491 by @Nielsvanpach) + +* Improve test suite, update dependencies and report failed assertions. + (#462 and #501 by @clue and #466 and #492 by @SimonFrings) + +## 1.3.0 (2022-07-11) + +A major new feature release, see [**release announcement**](https://clue.engineering/2022/announcing-reactphp-async). + +* Feature: Add new Async component to core components. + (#458 by @clue) + +* Feature: Support PHP 8.1 release. + (#451 by @clue) + +* Improve documentation, update HTTP server example for reactphp/http v1.6.0 release. + (#449 and #459 by @clue and #457 by @nhedger) + +* Improve test suite, support PHPUnit 9 and update dependencies to avoid skipping tests. + (#450 and #454 by @clue and #455 by @SimonFrings) + +## 1.2.0 (2021-07-11) + +A major new feature release, see [**release announcement**](https://clue.engineering/2021/announcing-reactphp-default-loop). + +* Feature: Simplify usage by supporting new [default loop](https://reactphp.org/event-loop/#loop). + (#445 by @clue) + +## 1.1.0 (2020-07-11) + +A major new feature release, see [**release announcement**](https://clue.engineering/2020/announcing-reactphp-http). + +* Feature: Add event-driven, streaming HTTP client and server implementation via [`react/http`](https://reactphp.org/http/). + (#440 by @clue) + +* Update documentation to link to project meta repo and link to our official Gitter chat room. + (#432 and #433 by @clue) + +* Improve test suite to run tests on PHP 7.4 and add `.gitattributes` to exclude dev files from exports. + (#434 by @reedy and #439 by @clue) + ## 1.0.0 (2019-07-11) * First stable LTS release, now following [SemVer](https://semver.org/). diff --git a/README.md b/README.md index b8d6aa53..f8e1d0f2 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@
- Build Status + Build Status

@@ -22,6 +22,28 @@ Streams abstraction, async DNS resolver, network client/server, HTTP client/server and interaction with processes. Third-party libraries can use these components to create async network clients/servers and more. +```php +listen($socket); + +echo "Server running at http://127.0.0.1:8080" . PHP_EOL; +``` + +This simple web server written in ReactPHP responds with "Hello World!" for every request. + ReactPHP is production ready and battle-tested with millions of installations from all kinds of projects around the world. Its event-driven architecture makes it a perfect fit for efficient network servers and clients handling hundreds or @@ -68,6 +90,9 @@ Node.js (V8). Promises/A implementation for PHP. [Read the documentation](https://github.com/reactphp/promise) +* **Async** + Async utilities and fibers for ReactPHP. + [Read the documentation](https://github.com/reactphp/async) ## Network Components @@ -79,16 +104,10 @@ Node.js (V8). Event-driven UDP client and server sockets for ReactPHP. [Read the documentation](https://github.com/reactphp/datagram) -## Protocol Components - * **HTTP** - Event-driven, streaming plaintext HTTP and secure HTTPS server for ReactPHP. + Event-driven, streaming HTTP client and server implementation for ReactPHP. [Read the documentation](https://github.com/reactphp/http) -* **HTTPClient** - Event-driven, streaming HTTP client for ReactPHP. - [Read the documentation](https://github.com/reactphp/http-client) - * **DNS** Async DNS resolver for ReactPHP. [Read the documentation](https://github.com/reactphp/dns) @@ -111,7 +130,6 @@ Node.js (V8). The missing link between Promise-land and Stream-land, built on top of ReactPHP. [Read the documentation](https://github.com/reactphp/promise-stream) - ## Built with ReactPHP * **Thruway** @@ -184,14 +202,14 @@ This means that instead of installing something like a "ReactPHP framework", you pick only the components that you need. This project follows [SemVer](https://semver.org/) for all its stable components. -The recommended way to install these components is [through Composer](https://getcomposer.org). -[New to Composer?](http://getcomposer.org/doc/00-intro.md) +The recommended way to install these components is [through Composer](https://getcomposer.org/). +[New to Composer?](https://getcomposer.org/doc/00-intro.md) For example, this may look something like this: ```bash # recommended install: pick required components -$ composer require react/event-loop react/http +composer require react/event-loop react/http ``` As an alternative, we also provide a meta package that will install all stable @@ -201,10 +219,10 @@ installed like this: ```bash # quick protoyping only: install all stable components -$ composer require react/react:^1.0 +composer require react/react:^1.4 ``` -For more details, check out [ReactPHP's homepage](https://reactphp.org) for +For more details, check out [ReactPHP's homepage](https://reactphp.org/) for quickstart examples and usage details. See also the combined [changelog for all ReactPHP components](https://reactphp.org/changelog.html) @@ -251,25 +269,25 @@ Thank you! ## Tests To run the test suite, you first need to clone this repo and then install all -dependencies [through Composer](https://getcomposer.org): +dependencies [through Composer](https://getcomposer.org/): ```bash -$ composer install +composer install ``` To run the test suite, go to the project root and run: ```bash -$ php vendor/bin/phpunit +vendor/bin/phpunit ``` The test suite also contains a number of functional integration tests that rely on a stable internet connection. Due to the vast number of integration tests, -these are skipped by default on Travis CI. If you also do not want to run these, +these are skipped by default during CI runs. If you also do not want to run these, they can simply be skipped like this: ```bash -$ php vendor/bin/phpunit --exclude-group internet +vendor/bin/phpunit --exclude-group internet ``` ## License diff --git a/composer.json b/composer.json index 90586b7f..3f752a63 100644 --- a/composer.json +++ b/composer.json @@ -9,17 +9,24 @@ }, "require": { "php": ">=5.3.8", - "react/cache": "^1.0", - "react/dns": "^1.0", - "react/event-loop": "^1.0", - "react/promise": "^2.1 || ^1.2", - "react/promise-stream": "^1.1.1", - "react/socket": "^1.0", - "react/stream": "^1.0" + "react/async": "^4.3 || ^3.2 || ^2.2", + "react/cache": "^1.1", + "react/dns": "^1.13", + "react/event-loop": "^1.5", + "react/http": "^1.11", + "react/promise": "^3.2 || ^2.10 || ^1.3", + "react/promise-stream": "^1.7", + "react/promise-timer": "^1.11", + "react/socket": "^1.15", + "react/stream": "^1.4" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^4.8.35", - "clue/block-react": "^1.1", - "clue/stream-filter": "^1.3" + "clue/stream-filter": "^1.3", + "phpunit/phpunit": "^9.6 || ^7.5 || ^5.7 || ^4.8.36" + }, + "config": { + "preferred-install": { + "react/*": "source" + } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4954d676..d5d26a2e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,28 +1,30 @@ - + + cacheResult="false" + colors="true" + convertDeprecationsToExceptions="true"> - + + + ./vendor/react/event-loop/tests/ ./vendor/react/*/tests/ - - ./vendor/react/socket/tests/ConnectorTest.php - ./vendor/react/socket/tests/DnsConnectorTest.php - - - + + ./vendor/react/*/src/ - - + + + + + + + + + + diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy new file mode 100644 index 00000000..2cd2f9b1 --- /dev/null +++ b/phpunit.xml.legacy @@ -0,0 +1,26 @@ + + + + + + + ./vendor/react/*/tests/ + + + + + ./vendor/react/*/src/ + + + + + + + + + + + diff --git a/tests/bootstrap.php b/tests/bootstrap.php index db5b8cac..2af732cf 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,9 @@ $autoload = require __DIR__ . '/../vendor/autoload.php'; -// register all `autoload-dev` paths from React's components +assert($autoload instanceof Composer\Autoload\ClassLoader); + +// register all `autoload-dev` paths from ReactPHP's components foreach (glob(__DIR__ . '/../vendor/react/*/composer.json') as $b) { $config = json_decode(file_get_contents($b), true); @@ -15,17 +17,3 @@ } } } - -// load all legacy test bootstrap scripts from React's components -foreach (glob(__DIR__ . '/../vendor/react/*/tests/bootstrap.php') as $b) { - // skip legacy react/promise for now and use manual autoload path from bootstrap config - // @link https://github.com/reactphp/promise/blob/1.x/tests/bootstrap.php - // @link https://github.com/reactphp/promise/blob/2.x/tests/bootstrap.php - if (strpos($b, 'react/promise/tests/bootstrap.php') !== false) { - $autoload->add('React\Promise', __DIR__ . '/../vendor/react/promise/tests'); - $autoload->addPsr4('React\\Promise\\', __DIR__ . '/../vendor/react/promise/tests'); - continue; - } - - include $b; -}