Skip to content

Commit c5a8e71

Browse files
authored
Merge pull request #4 from driftphp/feature/fixed-readme
Fixed readme
2 parents 85faa33 + a5864d6 commit c5a8e71

File tree

2 files changed

+43
-144
lines changed

2 files changed

+43
-144
lines changed

.circleci/config.yml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
version: 2
22
jobs:
3-
build:
3+
test-php72:
44
docker:
5-
- image: circleci/php:7.1-cli
5+
- image: circleci/php:7.2-cli
66

77
working_directory: ~/project
88
steps:
@@ -14,7 +14,39 @@ jobs:
1414
composer require phpunit/phpunit:7.5.17 --no-update
1515
1616
- run:
17-
name: Run tests
17+
name: Run tests / Symfony 4^3
18+
command: |
19+
composer update -n --prefer-dist --prefer-lowest --no-suggest
20+
php vendor/bin/phpunit --testsuite=base
21+
22+
- run:
23+
name: Run tests / Symfony 5^0
1824
command: |
1925
composer update -n --prefer-dist --no-suggest
20-
php vendor/bin/phpunit
26+
php vendor/bin/phpunit --testsuite=base
27+
28+
test-php74:
29+
docker:
30+
- image: circleci/php:7.4-cli
31+
32+
working_directory: ~/project
33+
steps:
34+
- checkout
35+
36+
- run:
37+
name: Install PHPUnit
38+
command: |
39+
composer require phpunit/phpunit:7.5.17 --no-update
40+
41+
- run:
42+
name: Run tests / Symfony 5^0
43+
command: |
44+
composer update -n --prefer-dist --no-suggest
45+
php vendor/bin/phpunit --testsuite=base
46+
47+
workflows:
48+
version: 2
49+
test:
50+
jobs:
51+
- test-php72
52+
- test-php74

README.md

Lines changed: 7 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,15 @@
11
# ReactPHP functions
22

3-
Set of simple PHP functions turned non-blocking on too of
4-
[ReactPHP](https://reactphp.org/)
5-
63
[![CircleCI](https://circleci.com/gh/driftphp/reactphp-functions.svg?style=svg)](https://circleci.com/gh/driftphp/reactphp-functions)
74

8-
**Table of Contents**
9-
- [Quickstart example](#quickstart-example)
10-
- [Usage](#usage)
11-
- [sleep()](#sleep)
12-
- [usleep()](#usleep)
13-
- [mime_content_type()](#mime_content_type)
14-
- [Install](#install)
15-
- [Tests](#tests)
16-
- [License](#license)
17-
18-
## Quickstart example
19-
20-
You can easily add a sleep in your non-blocking code by using these functions.
21-
In this code you can wait 1 second before continuing with the execution of your
22-
promise, while the loop is actively switching between active Promises.
23-
24-
```php
25-
// use a unique event loop instance for all parallel operations
26-
$loop = React\EventLoop\Factory::create();
27-
28-
$promise = $this
29-
->doWhateverNonBlocking($loop)
30-
->then(function() use ($loop) {
31-
32-
// This will be executed on time t=0
33-
return React\sleep(1, $loop);
34-
})
35-
->then(function() {
36-
37-
// This will be executed on time t=1
38-
});
39-
```
40-
41-
## Usage
42-
43-
This lightweight library has some small methods with the exact behavior than
44-
their sibling methods in regular and blocking PHP.
45-
46-
```php
47-
use Drift\React;
48-
49-
React\sleep(...);
50-
```
51-
52-
## EventLoop
53-
54-
Each function is responsible for orchestrating the [EventLoop](https://github.com/reactphp/event-loop#usage)
55-
in order to make it run (block) until your conditions are fulfilled.
56-
57-
```php
58-
$loop = React\EventLoop\Factory::create();
59-
```
60-
61-
### sleep
62-
63-
The `sleep($seconds, LoopInterface $loop)` method can be used to sleep for
64-
$time seconds.
65-
66-
```php
67-
React\sleep(1.5, $loop)
68-
->then(function() {
69-
// Do whatever you need after 1.5 seconds
70-
});
71-
```
72-
73-
It is important to understand all the possible sleep implementations you can use
74-
under this reactive programming environment.
75-
76-
- `\sleep($time)` - Block the PHP thread n seconds, and after this time is
77-
elapsed, continue from the same point
78-
- `\Clue\React\Block\sleep($time, $loop` - Don't block the PHP thread, but let
79-
the loop continue doing cycles. Block the program execution after n seconds, and
80-
after this time is elapsed, continue from the same point. This is a blocking
81-
feature.
82-
- `\Drift\React\sleep($time, $loop)` - Don't block neither the PHP thread nor
83-
the program execution. This method returns a Promise that will be resolved after
84-
n seconds. This is a non-blocking feature.
85-
86-
### usleep
87-
88-
The `sleep($seconds, LoopInterface $loop)` method can be used to sleep for
89-
$time microseconds.
90-
91-
```php
92-
React\usleep(3000, $loop)
93-
->then(function() {
94-
// Do whatever you need after 3000 microseconds
95-
});
96-
```
97-
98-
The same rationale than the [`React\sleep`](#sleep) method. This is a
99-
non-blocking action.
100-
101-
### mime_content_type
102-
103-
The `mime_content_type("/tmp/file.png", LoopInterface $loop)` method can be used
104-
to guess the mime content type of a file. If failure, then rejects with a
105-
RuntimeException.
106-
107-
```php
108-
React\mime_content_type("/tmp/file.png", $loop)
109-
->then(function(string $type) {
110-
// Do whatever you need with the found mime type
111-
});
112-
```
113-
114-
This is a non-blocking action and equals the regular PHP function
115-
[mime_content_type](https://www.php.net/manual/en/function.mime-content-type.php).
116-
117-
## Install
118-
119-
The recommended way to install this library is [through Composer](https://getcomposer.org).
120-
[New to Composer?](https://getcomposer.org/doc/00-intro.md)
121-
122-
This project follows [SemVer](https://semver.org/).
123-
This will install the latest supported version:
124-
125-
```bash
126-
$ composer require driftphp/react-functions:dev-master
127-
```
128-
129-
This library requires PHP7.
130-
131-
## Tests
132-
133-
To run the test suite, you first need to clone this repo and then install all
134-
dependencies [through Composer](https://getcomposer.org):
135-
136-
```bash
137-
$ composer install
138-
```
5+
Set of simple PHP functions turned non-blocking on too of
6+
[ReactPHP](https://reactphp.org/).
1397

140-
To run the test suite, go to the project root and run:
8+
Some first steps for you!
1419

142-
```bash
143-
$ php vendor/bin/phpunit
144-
```
10+
- [Go to DOCS](https://driftphp.io/#/?id=reactphp-functions)
14511

146-
## License
12+
or
14713

148-
This project is released under the permissive [MIT license](LICENSE).
14+
- [Try a demo](https://github.com/driftphp/demo)
15+
- [Install the skeleton](https://github.com/driftphp/skeleton)

0 commit comments

Comments
 (0)