This package is available on [Packagist](https://packagist.org/packages/joopschilder/php-async) and can be installed using [Composer](https://getcomposer.org/):
This package provides functions to run callables asynchronously in PHP. Return values are shared via System-V shared memory.
To use this package, you need PHP >= 7 with `ext-sysvshm` and `ext-pcntl`.
You should consider the state of this package to be __highly experimental__.
___Note:__ This package should not be used in a CGI environment._
The key that is used to access the block of shared memory is created based on the inode information of one of the source files.
This means that, whenever multiple instances (processes) from the same project source are created, they will try to use the same block of memory and collisions will occur.
I might swap the `ftok()` call for a multi-instance supporting mechanism later on (feel free to do so yourself).
___Note:__ It is possible (but discouraged) to change the amount of available shared memory._
If you wish to do so, it's as simple as calling either `Runtime::setSharedMemorySizeMB(<amount of MB>)` or `Runtime::setSharedMemorySizeB(<amount of bytes>)`.
If you want to use 32MB for example, call `Runtime::setSharedMemorySizeMB(32)`.<br/>
Be sure to make this call before using any of the asynchronous functionalities.
## What is this not?
This is, as you probably guessed by now, not intended for use in a production environment.
I'm not saying you _can't_, I'm just saying you _shouldn't_.
The code is _not_ unit tested. It has been documented throughout though, so feel free to take a look.
The only reason `curl` is used here is to provide an intuitive example.
If you really wanted to perform concurrent http requests you should look into either [`curl_multi_init`](http://php.net/manual/en/function.curl-multi-init.php) or just use [Guzzle](http://docs.guzzlephp.org/en/stable/).