Ref: https://github.com/huang-yi/laravel-swoole-http
My setting:
|
1 2 3 4 5 |
php version: PHP 7.3.9-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep 2 2019 12:54:04) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies Swoole version: 4.4.5 |
Create a laravel project. I tried version 6.x but I can’t use ‘laravel-swoole-http’ so I installed version 5.6.x
|
1 |
composer create-project --prefer-dist laravel/laravel laravel-swoole "5.6.*" |
Then go to the dir ‘laravel-swoole’ then install laravel-swoole-http’ with ‘composer require huang-yi/laravel-swoole-http’
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
composer require huang-yi/laravel-swoole-http Using version ^3.1 for huang-yi/laravel-swoole-http ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 2 installs, 0 updates, 0 removals - Installing huang-yi/swoole-watcher (0.0.2): Downloading (100%) - Installing huang-yi/laravel-swoole-http (3.1.7):Downloading (100%) ) Writing lock file Generating optimized autoload files Carbon 1 is deprecated, see how to migrate to Carbon 2. https://carbon.nesbot.com/docs/#api-carbon-2 You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it. > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover Discovered Package: fideloper/proxy Discovered Package: huang-yi/laravel-swoole-http Discovered Package: laravel/tinker Discovered Package: nunomaduro/collision Package manifest generated successfully. |
then register/publish the swoole service
|
1 2 3 4 |
php artisan vendor:publish --provider="HuangYi\Swoole\SwooleServiceProvider" Copied File [/vendor/huang-yi/laravel-swoole-http/config/swoole.php] To [/config/swoole.php] Publishing complete. |
then start swoole server
|
1 2 3 4 |
php artisan swoole:server Starting server... > (Run this command to ensure the server process is running: ps -ef|grep "{app.name}") |
open it on your browser: http://127.0.0.1:1215/
the setting in laravel-swoole/config/swoole.php like host (localhost), port (1215), etc
TO stop the swoole server:
|
1 2 3 4 |
php artisan swoole:server stop Stopping server... > success |
ANOTHER ACTIVE LARAVEL SWOOLE (laravel-swooletw)
https://github.com/swooletw/laravel-swoole
PLS READ https://github.com/swooletw/laravel-swoole/wiki
Create a laravel project. I installed version 5.6.x
|
1 |
composer create-project --prefer-dist laravel/laravel laravel-swooletw "5.6.*" |
Then go to the dir ‘laravel-swooletw’ then install laravel-swoole’ with ‘composer require swooletw/laravel-swoole’
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
composer require swooletw/laravel-swoole Using version ^2.6 for swooletw/laravel-swoole ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 2 installs, 0 updates, 0 removals - Installing predis/predis (v1.1.1): Downloading (100%) - Installing swooletw/laravel-swoole (v2.6.64): Downloading (100%) predis/predis suggests installing ext-phpiredis (Allows faster serialization and deserialization of the Redis protocol) Writing lock file Generating optimized autoload files Carbon 1 is deprecated, see how to migrate to Carbon 2. https://carbon.nesbot.com/docs/#api-carbon-2 You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it. > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover Discovered Package: fideloper/proxy Discovered Package: laravel/tinker Discovered Package: nunomaduro/collision Discovered Package: swooletw/laravel-swoole Package manifest generated successfully. |
from https://github.com/swooletw/laravel-swoole/wiki/4.-Installation,I need to register the swoole service provider in config/app.php
|
1 2 3 4 5 6 7 |
... 'providers' => [ ... SwooleTW\Http\LaravelServiceProvider::class, ], |
Then need to publish the configuration
|
1 2 3 4 5 6 |
php artisan vendor:publish --tag=laravel-swoole Copied File [/vendor/swooletw/laravel-swoole/config/swoole_http.php] To [/config/swoole_http.php] Copied File [/vendor/swooletw/laravel-swoole/config/swoole_websocket.php] To [/config/swoole_websocket.php] Copied File [/vendor/swooletw/laravel-swoole/routes/websocket.php] To [/routes/websocket.php] Publishing complete. |
Then run the server :
|
1 |
php artisan swoole:http start |
open it on your browser: http://localhost:1215/
ANOTHER LARAVEL – SWOOLE IS
https://github.com/hhxsv5/laravel-s
I download for auction app from https://github.com/GallopYD/domain-spider
STEPS:
|
1 2 3 4 5 |
git clone https://github.com/GallopYD/domain-spider laravel-auction cd laravel-auction composer install |
CREATE A .env file:
|
1 2 3 4 5 6 7 8 9 10 11 |
APP_ENV=local APP_DEBUG=true APP_KEY=base64:CVSEtDyAtoBbQbZ5udq3vbrM8+URejsZSOFwqA7dBAE= DB_HOST=localhost DB_DATABASE=laravel_auction_swoole DB_USERNAME=root DB_PASSWORD=teddy CACHE_DRIVER=file SESSION_DRIVER=file |
CREATE A NEW DATABASE ‘laravel_auction_swoole’ COLLATION : utf8mb4_unicode_ci
RUN
|
1 2 3 4 5 6 7 8 9 |
teddy@teddy:~/Documents/works/swoole/laravel-auction$ php artisan help -V Laravel Framework 5.6.39 teddy@teddy:~/Documents/works/swoole/laravel-auction$ php artisan key:generate Application key [base64:CVSEtDyAtoBbQbZ5udq3vbrM8+URejsZSOFwqA7dBAE=] set successfully. teddy@teddy:~/Documents/works/swoole/laravel-auction$ php artisan migrate --seedMigration table created successfully. Migrating: 2019_08_11_111354_create_domains_table Migrated: 2019_08_11_111354_create_domains_table |
READ https://github.com/hhxsv5/laravel-s
PUBLISH
|
1 2 3 4 5 6 7 8 9 |
teddy@teddy:~/Documents/works/swoole/laravel-auction$ php artisan laravels publish /home/teddy/Documents/works/swoole/laravel-auction/config/laravels.php already exists, do you want to override it ? Y/N [N]: > Y Copied file [/home/teddy/Documents/works/swoole/laravel-auction/vendor/hhxsv5/laravel-s/config/laravels.php] To [/home/teddy/Documents/works/swoole/laravel-auction/config/laravels.php] Linked file [/home/teddy/Documents/works/swoole/laravel-auction/vendor/hhxsv5/laravel-s/bin/laravels] To [/home/teddy/Documents/works/swoole/laravel-auction/bin/laravels] Linked file [/home/teddy/Documents/works/swoole/laravel-auction/vendor/hhxsv5/laravel-s/bin/fswatch] To [/home/teddy/Documents/works/swoole/laravel-auction/bin/fswatch] Linked file [/home/teddy/Documents/works/swoole/laravel-auction/vendor/hhxsv5/laravel-s/bin/inotify] To [/home/teddy/Documents/works/swoole/laravel-auction/bin/inotify] |
START SERVER
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
teddy@teddy:~/Documents/works/swoole/laravel-auction$ php bin/laravels start _ _ _____ | | | |/ ____| | | __ _ _ __ __ ___ _____| | (___ | | / _` | '__/ _` \ \ / / _ \ |\___ \ | |___| (_| | | | (_| |\ V / __/ |____) | |______\__,_|_| \__,_| \_/ \___|_|_____/ Speed up your Laravel/Lumen >>> Components +---------------------------+--------------------------------------+ | Component | Version | +---------------------------+--------------------------------------+ | PHP | 7.3.9-1+ubuntu16.04.1+deb.sury.org+1 | | Swoole | 4.4.5 | | LaravelS | 3.5.10 | | Laravel Framework [local] | 5.6.39 | +---------------------------+--------------------------------------+ >>> Protocols +-----------+--------+-------------------+----------------+ | Protocol | Status | Handler | Listen At | +-----------+--------+-------------------+----------------+ | Main HTTP | On | Laravel Framework | 127.0.0.1:5200 | +-----------+--------+-------------------+----------------+ >>> Feedback: https://github.com/hhxsv5/laravel-s [2019-09-21 16:54:46] [TRACE] Swoole is running, press Ctrl+C to quit. |
OPEN IT ON THE BROWSER : http://localhost:5200/