Download the PHP package huang-yi/laravel-swoole-http without Composer
On this page you can find all versions of the php package huang-yi/laravel-swoole-http. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-swoole-http
Laravel-Swoole-Http
A high performance HTTP server based on Swoole. And now, it also supports WebSocket server.
Translations
- 中文文档
Requirements
- Laravel/Lumen 5.2+
- ext-swoole 1.9.5+
- ext-inotify (Optional)
Installation & Setup
-
This package can be installed via composer:
- Register service provider(Optional)
You need to register the service provider manually, if your Laravel version is less than 5.5 or you are using Lumen:
- Configurations
Run this command to publish the configuration file:
Click here for more information about the configurations.
- Start server
Run this command to start the server:
And then, you can visit your website via http://127.0.0.1:1215.
Click here for more information about the commands.
Configurations
driver
This option controls the default "driver" that will be used to create the server.
Supported: "http", "websocket"
host
The ip address of the server.
port
The port of the server.
options
The swoole server configurations. Get more information from the official documents.
Notice: The value of
task_worker_num
must be greater than 0 if you use task.
resets
This option controls the instances that need to be reset after each request. It helps developers avoid problems caused by singleton, such as auth
.
message_parser
The WebSocket message parser. You can replace this option with a custom parser.
Notice: The custom parser must implement the
HuangYi\Swoole\Contracts\ParserContract
.
redis
connection
: Specify a redis connection to store websocket rooms and clients.prefix
: Set the prefix of redis key.
tables
Define swoole table structures:
name
: Specifies a table name.size
: Defines the maximum number of rows.columns
: Defines the table's columns. Format: [column_name
,column_type
,column_length
]. Column types:int
,integer
,string
,varchar
,char
,float
.
Click here for more information about the tables.
watcher
The file watcher configurations.
directories
:Defines the list of directories being watched;
excluded_directories
:Defines a list of directories not being watched;
suffixes
:Defines the list of file suffixes being watched.
Commands
This package provides an artisan command to manage the swoole server.
This command has an "action" argument and the default value is "start".
Actions | Description |
---|---|
start | Start the swoole server. |
stop | Stop the swoole server. |
reload | Reload the swoole server. |
restart | Restart the swoole server. |
watch | Enter the watch mode. The swoole server will reload automatically when the watched files changed. |
Notice: The swoole server can only run in cli environment.
Tables
The Swoole Table can help developers to share data across worker processes. You can define the table structures in the configuration file.
Click here for more information about the Swoole Tables.
Task
Define a task:
Send the task to the task worker processes:
Notice: To start the task worker processes, the value of
task_worker_num
must be set to greater than 0.
Nginx
Notice: Add the ip of swoole server (the default is 127.0.0.1) to the middleware
App\Http\Middleware\TrustProxies
.
Tips
- Never use these functions:
sleep()
、exit()
、die()
. - Be careful of the singletons.
All versions of laravel-swoole-http with dependencies
huang-yi/swoole-watcher Version 0.0.*
illuminate/console Version ~5.2
illuminate/contracts Version ~5.2
illuminate/events Version ~5.2
illuminate/http Version ~5.2
illuminate/pipeline Version ~5.2
illuminate/redis Version ~5.2
illuminate/support Version ~5.2
league/flysystem Version ^1.0