Download the PHP package zd04/laravel-s without Composer

On this page you can find all versions of the php package zd04/laravel-s. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-s

πŸš€ LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.

Please Watch this repository to get the latest updates.

Latest Stable Version Latest Unstable Version Total Downloads License Build Status Code Intelligence Status

δΈ­ζ–‡ζ–‡ζ‘£

Table of Contents

Features

Requirements

Dependency Requirement
PHP >= 5.5.9 Recommend PHP7+
Swoole >= 1.7.19 No longer support PHP5 since 2.0.12 Recommend 4.2.3+
Laravel/Lumen >= 5.1 Recommend 5.6+

Install

1.Require package via Composer(packagist).

2.Register service provider(pick one of two).

3.Publish configuration and binaries.

After upgrading LaravelS, you need to republish; click here to see the change notes of each version.

4.Change config/laravels.php: listen_ip, listen_port, refer Settings.

Run

Please read the notices carefully before running, Important notices(IMPORTANT).

Command Description
start Start LaravelS, list the processes by "ps -ef|grep laravels". Support the option "-d|--daemonize" to run as a daemon; Support the option "-e|--env" to specify the environment to run, such as --env=testing will use the configuration file .env.testing firstly, this feature requires Laravel 5.2+
stop Stop LaravelS
restart Restart LaravelS, support the options "-d|--daemonize" and "-e|--env"
reload Reload all Task/Worker/Timer processes which contain your business codes, and trigger the method onReload of Custom process, CANNOT reload Master/Manger processes. After modifying config/laravels.php, you can only call restart to restart
info Display component version information
help Display help information
File Description
storage/laravels.json LaravelS's runtime configuration file
storage/laravels.pid PID file of Master process
storage/laravels-timer-process.pid PID file of the Timer process
storage/laravels-custom-processes.pid PID file of all custom processes

Deploy

It is recommended to supervise the main process through Supervisord, the premise is without option -d and to set swoole.daemonize to false.

Cooperate with Nginx (Recommended)

Demo.

Cooperate with Apache

Enable WebSocket server

The Listening address of WebSocket Sever is the same as Http Server.

1.Create WebSocket Handler class, and implement interface WebSocketHandlerInterface.The instant is automatically instantiated when start, you do not need to manually create it.

2.Modify config/laravels.php.

3.Use SwooleTable to bind FD & UserId, optional, Swoole Table Demo. Also you can use the other global storage services, like Redis/Memcached/MySQL, but be careful that FD will be possible conflicting between multiple Swoole Servers.

4.Cooperate with Nginx (Recommended)

Refer WebSocket Proxy

5.Heartbeat setting

6.Push data in controller

Listen events

System events

Usually, you can reset/destroy some global/static variables, or change the current Request/Response object.

Customized asynchronous events

This feature depends on AsyncTask of Swoole, your need to set swoole.task_worker_num in config/laravels.php firstly. The performance of asynchronous event processing is influenced by number of Swoole task process, you need to set task_worker_num appropriately.

1.Create event class.

2.Create listener class.

3.Fire event.

Asynchronous task queue

This feature depends on AsyncTask of Swoole, your need to set swoole.task_worker_num in config/laravels.php firstly. The performance of task processing is influenced by number of Swoole task process, you need to set task_worker_num appropriately.

1.Create task class.

2.Deliver task.

Millisecond cron job

Wrapper cron job base on Swoole's Millisecond Timer, replace Linux Crontab.

1.Create cron job class.

2.Register cron job.

3.Note: it will launch multiple timers when build the server cluster, so you need to make sure that launch one timer only to avoid running repetitive task.

4.LaravelS v3.4.0 starts to support the hot restart [Reload] Timer process. After LaravelS receives the SIGUSR1 signal, it waits for max_wait_time(default 5) seconds to end the process, then the Manager process will pull up the Timer process again.

5.If you only need to use minute-level scheduled tasks, it is recommended to enable Hhxsv5\LaravelS\Illuminate\LaravelScheduleJob instead of Linux Crontab, so that you can follow the coding habits of Laravel task scheduling and configure Kernel.

Automatically reload after modifying code

Get the instance of SwooleServer in your project

Use SwooleTable

1.Define Table, support multiple.

All defined tables will be created before Swoole starting.

2.Access Table: all table instances will be bound on SwooleServer, access by app('swoole')->xxxTable.

Multi-port mixed protocol

For more information, please refer to Swoole Server AddListener

To make our main server support more protocols not just Http and WebSocket, we bring the feature multi-port mixed protocol of Swoole in LaravelS and name it Socket. Now, you can build TCP/UDP applications easily on top of Laravel.

  1. Create socket handler class, and extend Hhxsv5\LaravelS\Swoole\Socket\{TcpSocket|UdpSocket|Http|WebSocket}.

    These Socket connections share the same worker processes with your HTTP/WebSocket connections. So it won't be a problem at all if you want to deliver tasks, use SwooleTable, even Laravel components such as DB, Eloquent and so on. At the same time, you can access Swoole\Server\Port object directly by member property swoolePort.

  2. Register Sockets.

    About the heartbeat configuration, it can only be set on the main server and cannot be configured on Socket, but the Socket inherits the heartbeat configuration of the main server.

    For TCP socket, onConnect and onClose events will be blocked when dispatch_mode of Swoole is 1/3, so if you want to unblock these two events please set dispatch_mode to 2/4/5.

  3. Test.
  1. Register example of other protocols.

    • UDP

    • Http

    • WebSocket: The main server must turn on WebSocket, that is, set websocket.enable to true.

Coroutine

Swoole Coroutine

Custom process

Support developers to create special work processes for monitoring, reporting, or other special tasks. Refer addProcess.

  1. Create Proccess class, implements CustomProcessInterface.

  2. Register TestProcess.

  3. Note: The callback() cannot quit. If quit, the Manager process will re-create the process.

  4. Example: Write data to a custom process.

Other features

Configuring the event callback function of Swoole

Supported events:

Event Interface When happened
ServerStart Hhxsv5\LaravelS\Swoole\Events\ServerStartInterface Occurs when the Master process is starting, this event should not handle complex business logic, and can only do some simple work of initialization.
ServerStop Hhxsv5\LaravelS\Swoole\Events\ServerStopInterface Occurs when the server exits normally, CANNOT use async or coroutine related APIs in this event.
WorkerStart Hhxsv5\LaravelS\Swoole\Events\WorkerStartInterface Occurs after the Worker/Task process is started, and the Laravel initialization has been completed.
WorkerStop Hhxsv5\LaravelS\Swoole\Events\WorkerStopInterface Occurs after the Worker/Task process exits normally
WorkerError Hhxsv5\LaravelS\Swoole\Events\WorkerErrorInterface Occurs when an exception or fatal error occurs in the Worker/Task process

1.Create an event class to implement the corresponding interface.

2.Configuration.

Important notices

  1. Redis connection, it won't reconnect automatically immediately after disconnect, and will throw an exception about lost connection, reconnect next time. You need to make sure that SELECT DB correctly before operating Redis every time.

Alternatives

Sponsor

License

MIT


All versions of laravel-s with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
symfony/console Version >=2.7.0
ext-json Version *
ext-pcntl Version *
swoole/ide-helper Version @dev
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zd04/laravel-s contains the following files

Loading the files please wait ....