Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tabuna/stone
Laravel Stone - HTTP server using the ReactPHP.
https://github.com/tabuna/stone
laravel php reactphp reactphp-server server
Last synced: 25 days ago
JSON representation
Laravel Stone - HTTP server using the ReactPHP.
- Host: GitHub
- URL: https://github.com/tabuna/stone
- Owner: tabuna
- License: mit
- Created: 2018-10-17T20:16:03.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-13T03:03:00.000Z (over 1 year ago)
- Last Synced: 2024-05-10T00:07:18.939Z (6 months ago)
- Topics: laravel, php, reactphp, reactphp-server, server
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Stone - HTTP server using the ReactPHP
With ReactPHP we keep our application alive between requests so we only execute this bootstrap once when starting the server: the footprint is absent from Requests.
However now the tables are turned: we're vulnerable to memory consumption, fatal error, statefulness and code update worries.## Installation
Installer using Composer:
```bash
$ composer require tabuna/stone
```## Example
The easiest way to run:
```bash
$ php vendor/bin/stone
```You can also specify a port:
```bash
$ php vendor/bin/stone -p 8000
```It does not interfere with your application, so do not worry
## Making production ready
### Supervisord
Install Supervisord
```bash
$ sudo apt-get install -y supervisor
```Here's a configuration example (create a `*.conf` file in `/etc/supervisord/conf.d`):
```bash
[program:laravel-stone-server]
command=php /path/to/your/code/vendor/bin/stone -p 800%(process_num)
process_name=%(program_name)s-%(process_num)d
numprocs=4
umask=022
user=foobar
stdout_logfile=/var/log/supervisord/%(program_name)s-%(process_num)d.log ; stdout log path, NONE for none; default AUTO
stderr_logfile=/var/log/supervisord/%(program_name)s-%(process_num)d-error.log ; stderr log path, NONE for none; default AUTO
autostart=true
autorestart=true
startretries=3
```It will:
- run 4 servers on ports 8000, 8001, 8002 and 8003
- it restarts them automatically when they crash (will try a maximum of 3 times, then give up)### Nginx as Load-Balancer
What we do here is to proxy only requests that donβt point to a local file.
```bash
upstream stone {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}server {
listen 80;
server_name example.com;
root /example.com/public;add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }error_page 404 /index.php;
location ~ \.php$ {
proxy_pass http://stone;
break;
}location ~ /\.(?!well-known).* {
deny all;
}
}
```## Donate & Support
If you would like to support development by making a donation you can do so [here](https://www.paypal.me/tabuna/10usd). π
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.