Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit f724d83

Browse files
authored
Update README.md
1 parent a287b95 commit f724d83

File tree

1 file changed

+70
-7
lines changed

1 file changed

+70
-7
lines changed

README.md

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ This package provides a high performance HTTP server to speed up your laravel/lu
1212
|:-------:|:-------:|:-----:|:-------:|
1313
| >=5.5.9 | ~5.1 | ~5.1 | >=1.9.3 |
1414

15-
## Quick Start
15+
## Installation
1616

1717
Require this package with composer by using the following command:
1818

1919
```
2020
$ composer require swooletw/laravel-swoole
2121
```
2222

23+
> This package relies on Swoole. Please make sure your machine has been installed the Swoole extension. Using this command to install quickly: `pecl install swoole`. Visit the [official website](https://wiki.swoole.com/wiki/page/6.html) for more information.
24+
2325
Then, add the service provider:
2426

2527
If you are using Laravel, add the service provider to the providers array in `config/app.php`:
@@ -38,13 +40,70 @@ If you are using Lumen, append the following code to `bootstrap/app.php`:
3840
$app->register(SwooleTW\Http\LumenServiceProvider::class);
3941
```
4042

43+
## Configuration
44+
45+
If you want to change the default configurations, please run the following command to generate a configuration file `http.php` in directory `config/`:
46+
47+
```
48+
$ php artisan vendor:publish
49+
```
50+
51+
`server.host`: The swoole_http_server host.
52+
53+
`server.port`: The swoole_http_server port.
54+
55+
`server.options`: The configurations for `Swoole\Server`. To get more information about swoole server, please read [the official documentation](https://wiki.swoole.com/wiki/page/274.html).
56+
57+
For example, if you want to set the 'max_request':
58+
59+
```php
60+
[
61+
'server' => [
62+
'options' => [
63+
'max_request' => 1000,
64+
],
65+
]
66+
]
67+
```
68+
69+
## Command
70+
71+
> The swoole_http_server can only run in cli environment, and this package provides convenient artisan commands to manage it.
72+
> By default, you can visit your site at http://127.0.0.1:1215
73+
74+
Start the swoole_http_server:
75+
76+
```
77+
$ php artisan swoole:http start
78+
```
79+
80+
Stop the swoole_http_server:
81+
82+
```
83+
$ php artisan swoole:http stop
84+
```
85+
86+
Restart the swoole_http_server:
87+
88+
```
89+
$ php artisan swoole:http restart
90+
```
91+
92+
Reload the swoole_http_server:
93+
94+
```
95+
$ php artisan swoole:http reload
96+
```
97+
4198
Now, you can run the following command to start the **swoole_http_server**.
4299

43100
```
44101
$ php artisan swoole:http start
45102
```
46103

47-
By default, you can visit your site at http://127.0.0.1:1215. And you can also configure domains via nginx proxy:
104+
## Nginx Configuration
105+
106+
> The support of swoole_http_server for Http is not complete. So, you should configure the domains via nginx proxy in your production environment.
48107
49108
```nginx
50109
server {
@@ -54,7 +113,8 @@ server {
54113
index index.php;
55114
56115
location = /index.php {
57-
# Ensure that there is no such file named "not_exists" in your "public" directory.
116+
# Ensure that there is no such file named "not_exists"
117+
# in your "public" directory.
58118
try_files /not_exists @swoole;
59119
}
60120
@@ -64,11 +124,11 @@ server {
64124
65125
location @swoole {
66126
set $suffix "";
67-
127+
68128
if ($uri = /index.php) {
69129
set $suffix "/";
70130
}
71-
131+
72132
proxy_set_header Host $host;
73133
proxy_set_header SERVER_PORT $server_port;
74134
proxy_set_header REMOTE_ADDR $remote_addr;
@@ -81,6 +141,7 @@ server {
81141
}
82142
}
83143
```
144+
84145
## Performance Reference
85146

86147
Test with clean Lumen 5.5, using MacBook Air 13, 2015.
@@ -116,9 +177,11 @@ Requests/sec: 8717.00
116177
Transfer/sec: 1.55MB
117178
```
118179

119-
## Documentation
180+
## Notices
120181

121-
- [Full Docuementation](docs/english.md)
182+
1. Please reload or restart the swoole_http_server after released your code. Because the Laravel program will be kept in memory after the swoole_http_server started. That's why the swoole_http_server has high performance.
183+
2. Never use `dd()`, `exit()` or `die()` function to print your debug message. It will terminate your swoole worker unexpectedly.
184+
3. You should have basic knowledge of multi-process programming and swoole. If you still write your code with a single-process conception, your app might have unexpected bugs.
122185

123186
## Support
124187

0 commit comments

Comments
 (0)