Download the PHP package huang-yi/shadowfax without Composer
On this page you can find all versions of the php package huang-yi/shadowfax. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package shadowfax
English | 中文
Shadowfax
The Shadowfax is a package that runs your Laravel application on Swoole.
Installation
You may use Composer to install Shadowfax to your project:
If you are using Lumen, you need to register the service provider manually in bootstrap/app.php
:
After installing Shadowfax, publish its configuration files using the shadowfax:publish
Artisan command:
Configuration
The primary configuration file is shadowfax.yml
. And this file name is added to the .gitignore
file by shadowfax:publish
Artisan command.
- Basic configuration:
- name: The processes name.
- type: The server type, support:
http
,websocket
. - host: The server host.
- port: The server port.
- mode: The server mode, support:
process
,base
. - access_log: Indicates whether to print the request information.
- app_pool_capacity: Set the capacity of the apps pool. Only valid when coroutine is enabled.
- framework_bootstrapper: Set Laravel bootstrap file. If you changed Laravel's directory structure, you should modify this value.
server
configuration:
This section defines the Swoole\Server
configuration. Read the official docs for more information.
abstracts
configuration:
This option allows you to set a group of abstracts in the Laravel IoC container. These abstracts will be rebound after each request.
controllers
configuration:
This option allows you to clean the controller instances in route after each request.
cleaners
configuration:
This option allows you to register custom cleaners. These cleaners will run after each request.
db_pools
configuration:
This option allows you to configure database connection pools. You can add multiple key-value pairs in here.
The key name is a connection name in your database.connections
, the key value is the connection pool capacity. e.g.:
redis_pools
configuration:
This option allows you to configure redis connection pools. You can add multiple key-value pairs in here.
The key name is a connection name in your database.redis
, the key value is the connection pool capacity. e.g.:
controller server
configuration:
This section defines the controller server configuration. The controller server allows you to stop or reload your Shadowfax.
Command
Shadowfax provides a shadowfax
command to manage your server processes. This command is build on the Symfony console component, so you can run php shadowfax list
for more information.
You may run the php shadowfax start
command to start Shadowfax server. The --watch|-w
option can run your Shadowfax in watch mode. In watch mode, the processes will be automatically reloaded when the files under your project change.
You must install the fswatch before using
--watch|-w
option.
The php shadowfax reload
allows you to reload the Shadowfax processes.
The php shadowfax stop
allows you to stop the Shadowfax server.
Database Connection Pool
Before using database connection pools, you must enable Swoole coroutine and configure the hook_flags:
Then, add your connection to the db_pools
option, and specify a pool capacity:
Redis Connection Pool
The difference with database connection pool is that redis connection pools are configured under the redis_pools
option.
WebSocket Server
Shadowfax also allows you to build your WebSocket server.
First of all, you need to change the value of configuration item type
to websocket
. Then create a handler class that implemented the HuangYi\Shadowfax\Contracts\WebSocket\Handler
interface:
And bind this handler to a uri in your route file:
Now, you can start the WebSocket server by command php shadowfax start
.
Nginx Configuration
You may use Nginx as a reverse proxy in production environment:
You need to add the IP address of the Shadowfax to the App\Http\Middleware\TrustProxies Middleware.
Supervisor Configuration
If you want to use the Supervisor to manage your Shadowfax processes, the following configuration file should suffice:
Benchmarks
Run tests using wrk.
Environment 1
- Hardware: 1 CPU, 4 Cores, 16GB Memory
- MacOS 10.15.3
- PHP 7.3.12 (with opcache)
- Swoole 4.4.13
- Laravel 7 (without session middleware)
- Shadowfax 2.0.0 (with 20 worker processes)
Result:
Environment 2
- Hardware: 2 CPUs, 2 Cores, 4GB Memory
- CentOS 7.5.1804
- PHP 7.3.16 (with opcache)
- Swoole 4.4.17
- Laravel 7 (without session middleware)
- Shadowfax 2.0.0 (with 10 worker processes)
Result:
Testing
License
Shadowfax is open-sourced software licensed under the MIT license.
All versions of shadowfax with dependencies
ext-swoole Version ^4.3.2
huang-yi/swoole-watcher Version ^1.0
illuminate/console Version ^5.5|^6.0|^7.0|^8.0
illuminate/container Version ^5.5|^6.0|^7.0|^8.0
illuminate/contracts Version ^5.5|^6.0|^7.0|^8.0
illuminate/http Version ^5.5|^6.0|^7.0|^8.0
illuminate/support Version ^5.5|^6.0|^7.0|^8.0
psr/container Version ^1.0
psr/event-dispatcher Version ^1.0
symfony/console Version ^3.3|^4.0|^5.0
symfony/yaml Version ^3.3|^4.0|^5.0