lamoimage / larasocket by lamoimage

a web socket server build with laravel and swoole
85
4
1
Package Data
Maintainer Username: lamoimage
Maintainer Contact: lamoimage@gmail.com (Lamoimage Z)
Package Create Date: 2016-09-27
Package Last Update: 2017-06-17
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:11:04
Package Statistics
Total Downloads: 85
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 4
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Larasocket - a web socket server build with laravel and swoole

##Screenshot enter image description here

Installation

Make sure you have the SWOOLE PHP package installed. You can find installation instructions at http://pecl.php.net/package/swoole and http://www.swoole.com

run below command to install swool extension and add "extension=swoole.so" to php.ini.

pecl install swoole

Now pull in Larasocket package through Composer.

Run composer require lamoimage/larasocket

And then, if using Laravel 5, include the service provider within config/app.php.

'providers' => [
    Lamoimage\Larasocket\LarasocketServiceProvider::class,
];

Usage

Start the socket service with php artisan socket:start command

php artisan socket:start

Then access the route /larasocket in browser:

If you are using homestead, the url looks like

http://homestead.app/larasocket

You may also do socket:stop/socket:restart to shutdown or restart the socket service.

  • php artisan socket:stop
  • php artisan socket:restart

If you need to modify the socket server partials, you can run:

php artisan vendor:publish

The SWOOLE config file will now be located in the config/larasocket.php.

If you want to handle your own socket service logic, just implement the socket interface located at vendor/lamoimage/larasocket/Socket.php, then register in app/Providers/AppServiceProvider.php,

public function register()
{
	$this->app->bind('Lamoimage\Larasocket\Socket', 'App\Services\MySocket');
}