Download the PHP package hhxsv5/laravel-s without Composer

On this page you can find all versions of the php package hhxsv5/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?
hhxsv5/laravel-s
Rate from 1 - 5
Rated 5.00 based on 9 reviews

Informations about the package laravel-s

LaravelS Logo

English Docs | δΈ­ζ–‡ζ–‡ζ‘£

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

Latest Version PHP Version Swoole Version Total Downloads Build Status Code Intelligence Status License


Continuous Updates

Table of Contents

Features

Benchmark

Requirements

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

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.

5.Performance tuning

Run

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

Command Description
start Start LaravelS, list the processes by "ps -ef|grep laravels"
stop Stop LaravelS, and trigger the method onStop of Custom process
restart Restart LaravelS: Stop gracefully before starting; The service is unavailable until startup is complete
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 only have to call restart to restart
info Display component version information
help Display help information
Option Description
-d|--daemonize Run as a daemon, this option will override the swoole.daemonize setting in laravels.php
-e|--env The environment the command should run under, such as --env=testing will use the configuration file .env.testing firstly, this feature requires Laravel 5.2+
-i|--ignore Ignore checking PID file of Master process
-x|--x-version The version(branch) of the current project, stored in $_ENV/$_SERVER, access via $_ENV['X_VERSION'] $_SERVER['X_VERSION'] $request->server->get('X_VERSION')
File Description
storage/laravels.conf 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.

Common components

Apollo

LaravelS will pull the Apollo configuration and write it to the .env file when starting. At the same time, LaravelS will start the custom process apollo to monitor the configuration and automatically reload when the configuration changes.

  1. Enable Apollo: add --enable-apollo and Apollo parameters to the startup parameters.

  2. Support hot updates(optional).

  3. List of available parameters.
Parameter Description Default Demo
apollo-server Apollo server URL - --apollo-server=http://127.0.0.1:8080
apollo-app-id Apollo APP ID - --apollo-app-id=LARAVEL-S-TEST
apollo-namespaces The namespace to which the APP belongs, support specify the multiple application --apollo-namespaces=application --apollo-namespaces=env
apollo-cluster The cluster to which the APP belongs default --apollo-cluster=default
apollo-client-ip IP of current instance, can also be used for grayscale publishing Local intranet IP --apollo-client-ip=10.2.1.83
apollo-pull-timeout Timeout time(seconds) when pulling configuration 5 --apollo-pull-timeout=5
apollo-backup-old-env Whether to backup the old configuration file when updating the configuration file .env false --apollo-backup-old-env

Prometheus

Support Prometheus monitoring and alarm, Grafana visually view monitoring metrics. Please refer to Docker Compose for the environment construction of Prometheus and Grafana.

  1. Require extension APCu >= 5.0.0, please install it by pecl install apcu.

  2. Copy the configuration file prometheus.php to the config directory of your project. Modify the configuration as appropriate.

    If your project is Lumen, you also need to manually load the configuration $app->configure('prometheus'); in bootstrap/app.php.

  3. Configure global middleware: Hhxsv5\LaravelS\Components\Prometheus\RequestMiddleware::class. In order to count the request time consumption as accurately as possible, RequestMiddleware must be the first global middleware, which needs to be placed in front of other middleware.

  4. Register ServiceProvider: Hhxsv5\LaravelS\Components\Prometheus\ServiceProvider::class.

  5. Configure the CollectorProcess in config/laravels.php to collect the metrics of Swoole Worker/Task/Timer processes regularly.

  6. Create the route to output metrics.

  7. Complete the configuration of Prometheus and start it.

  8. Start Grafana, then import panel json.
Grafana Dashboard

Other features

Configure Swoole events

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.

Serverless

Alibaba Cloud Function Compute

Function Compute.

1.Modify bootstrap/app.php and set the storage directory. Because the project directory is read-only, the /tmp directory can only be read and written.

2.Create a shell script laravels_bootstrap and grant executable permission.

3.Configure template.xml.

Important notices

Singleton Issue

Cleaners

Configuration cleaners.

Known issues

Known issues: a package of known issues and solutions.

Debugging method

Read request

Read request by Illuminate\Http\Request Object, $_ENV is readable, $_SERVER is partially readable, CANNOT USE $_GET/$_POST/$_FILES/$_COOKIE/$_REQUEST/$_SESSION/$GLOBALS.

Output response

Respond by Illuminate\Http\Response Object, compatible with echo/vardump()/print_r(),CANNOT USE functions dd()/exit()/die()/header()/setcookie()/http_response_code().

Persistent connection

Singleton connection will be resident in memory, it is recommended to turn on persistent connection for better performance.

  1. Database connection, it will reconnect automatically immediately after disconnect.

  2. 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.

About memory leaks

Linux kernel parameter adjustment

Linux kernel parameter adjustment

Pressure test

Pressure test

Alternatives

Sponsor

License

MIT


All versions of laravel-s with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
ext-curl Version *
ext-json Version *
ext-pcntl Version *
swoole/ide-helper Version @dev
symfony/console Version >=2.7.0
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 hhxsv5/laravel-s contains the following files

Loading the files please wait ....