You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+70-7Lines changed: 70 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,16 @@ This package provides a high performance HTTP server to speed up your laravel/lu
12
12
|:-------:|:-------:|:-----:|:-------:|
13
13
| >=5.5.9 |~5.1 |~5.1 | >=1.9.3 |
14
14
15
-
## Quick Start
15
+
## Installation
16
16
17
17
Require this package with composer by using the following command:
18
18
19
19
```
20
20
$ composer require swooletw/laravel-swoole
21
21
```
22
22
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
+
23
25
Then, add the service provider:
24
26
25
27
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`:
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
+
41
98
Now, you can run the following command to start the **swoole_http_server**.
42
99
43
100
```
44
101
$ php artisan swoole:http start
45
102
```
46
103
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.
48
107
49
108
```nginx
50
109
server {
@@ -54,7 +113,8 @@ server {
54
113
index index.php;
55
114
56
115
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.
58
118
try_files /not_exists @swoole;
59
119
}
60
120
@@ -64,11 +124,11 @@ server {
64
124
65
125
location @swoole {
66
126
set $suffix "";
67
-
127
+
68
128
if ($uri = /index.php) {
69
129
set $suffix "/";
70
130
}
71
-
131
+
72
132
proxy_set_header Host $host;
73
133
proxy_set_header SERVER_PORT $server_port;
74
134
proxy_set_header REMOTE_ADDR $remote_addr;
@@ -81,6 +141,7 @@ server {
81
141
}
82
142
}
83
143
```
144
+
84
145
## Performance Reference
85
146
86
147
Test with clean Lumen 5.5, using MacBook Air 13, 2015.
@@ -116,9 +177,11 @@ Requests/sec: 8717.00
116
177
Transfer/sec: 1.55MB
117
178
```
118
179
119
-
## Documentation
180
+
## Notices
120
181
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.
0 commit comments