{"id":4777,"date":"2019-09-19T14:35:19","date_gmt":"2019-09-19T14:35:19","guid":{"rendered":"http:\/\/myprojects.advchaweb.com\/?p=4777"},"modified":"2019-09-21T10:03:26","modified_gmt":"2019-09-21T10:03:26","slug":"laravel-and-swoole","status":"publish","type":"post","link":"https:\/\/myprojects.advchaweb.com\/index.php\/2019\/09\/19\/laravel-and-swoole\/","title":{"rendered":"Laravel and Swoole"},"content":{"rendered":"<p>Ref: https:\/\/github.com\/huang-yi\/laravel-swoole-http<br \/>\nMy setting:<\/p>\n<pre class=\"lang:default decode:true \">php version: PHP 7.3.9-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep  2 2019 12:54:04) ( NTS )\r\nCopyright (c) 1997-2018 The PHP Group\r\nZend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies\r\n\r\nSwoole version: 4.4.5<\/pre>\n<p>&nbsp;<\/p>\n<p>Create a laravel project. I tried version 6.x but I can&#8217;t use &#8216;laravel-swoole-http&#8217; so I installed version 5.6.x<\/p>\n<pre class=\"lang:default decode:true\">composer create-project --prefer-dist laravel\/laravel laravel-swoole \"5.6.*\"<\/pre>\n<p>Then go to the dir &#8216;laravel-swoole&#8217; then install laravel-swoole-http&#8217; with &#8216;composer require huang-yi\/laravel-swoole-http&#8217;<\/p>\n<pre class=\"lang:default decode:true\">composer require huang-yi\/laravel-swoole-http\r\n\r\nUsing version ^3.1 for huang-yi\/laravel-swoole-http\r\n.\/composer.json has been updated\r\nLoading composer repositories with package information\r\nUpdating dependencies (including require-dev)\r\nPackage operations: 2 installs, 0 updates, 0 removals\r\n  - Installing huang-yi\/swoole-watcher (0.0.2): Downloading (100%)         \r\n  - Installing huang-yi\/laravel-swoole-http (3.1.7):Downloading (100%)         )\r\nWriting lock file\r\nGenerating optimized autoload files\r\nCarbon 1 is deprecated, see how to migrate to Carbon 2.\r\nhttps:\/\/carbon.nesbot.com\/docs\/#api-carbon-2\r\n    You can run '.\/vendor\/bin\/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.\r\n&gt; Illuminate\\Foundation\\ComposerScripts::postAutoloadDump\r\n&gt; @php artisan package:discover\r\nDiscovered Package: fideloper\/proxy\r\nDiscovered Package: huang-yi\/laravel-swoole-http\r\nDiscovered Package: laravel\/tinker\r\nDiscovered Package: nunomaduro\/collision\r\nPackage manifest generated successfully.<\/pre>\n<p>then register\/publish the swoole service<\/p>\n<pre class=\"lang:default decode:true \">php artisan vendor:publish --provider=\"HuangYi\\Swoole\\SwooleServiceProvider\"\r\n\r\nCopied File [\/vendor\/huang-yi\/laravel-swoole-http\/config\/swoole.php] To [\/config\/swoole.php]\r\nPublishing complete.<\/pre>\n<p>then start swoole server<\/p>\n<pre class=\"lang:default decode:true\">php artisan swoole:server\r\n\r\nStarting server...\r\n&gt; (Run this command to ensure the server process is running: ps -ef|grep \"{app.name}\")<\/pre>\n<p>open it on your browser: http:\/\/127.0.0.1:1215\/<br \/>\nthe setting in laravel-swoole\/config\/swoole.php like host (localhost), port (1215), etc<br \/>\nTO stop the swoole server:<\/p>\n<pre class=\"lang:default decode:true \">php artisan swoole:server stop\r\n\r\nStopping server...\r\n&gt; success<\/pre>\n<p>ANOTHER ACTIVE LARAVEL SWOOLE (laravel-swooletw)<br \/>\nhttps:\/\/github.com\/swooletw\/laravel-swoole<br \/>\nPLS READ https:\/\/github.com\/swooletw\/laravel-swoole\/wiki<br \/>\nCreate a laravel project. I installed version 5.6.x<\/p>\n<pre class=\"lang:default decode:true\">composer create-project --prefer-dist laravel\/laravel laravel-swooletw \"5.6.*\"<\/pre>\n<p>Then go to the dir &#8216;laravel-swooletw&#8217; then install laravel-swoole&#8217; with &#8216;composer require swooletw\/laravel-swoole&#8217;<\/p>\n<pre class=\"lang:default decode:true \">composer require swooletw\/laravel-swoole\r\n\r\nUsing version ^2.6 for swooletw\/laravel-swoole\r\n.\/composer.json has been updated\r\nLoading composer repositories with package information\r\nUpdating dependencies (including require-dev)\r\nPackage operations: 2 installs, 0 updates, 0 removals\r\n  - Installing predis\/predis (v1.1.1): Downloading (100%)         \r\n  - Installing swooletw\/laravel-swoole (v2.6.64): Downloading (100%)         \r\npredis\/predis suggests installing ext-phpiredis (Allows faster serialization and deserialization of the Redis protocol)\r\nWriting lock file\r\nGenerating optimized autoload files\r\nCarbon 1 is deprecated, see how to migrate to Carbon 2.\r\nhttps:\/\/carbon.nesbot.com\/docs\/#api-carbon-2\r\n    You can run '.\/vendor\/bin\/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.\r\n&gt; Illuminate\\Foundation\\ComposerScripts::postAutoloadDump\r\n&gt; @php artisan package:discover\r\nDiscovered Package: fideloper\/proxy\r\nDiscovered Package: laravel\/tinker\r\nDiscovered Package: nunomaduro\/collision\r\nDiscovered Package: swooletw\/laravel-swoole\r\nPackage manifest generated successfully.<\/pre>\n<p>from https:\/\/github.com\/swooletw\/laravel-swoole\/wiki\/4.-Installation,I need to register the swoole service provider in config\/app.php<\/p>\n<pre class=\"lang:default decode:true \">    ...\r\n    'providers' =&gt; [\r\n\r\n       ...\r\n       SwooleTW\\Http\\LaravelServiceProvider::class,\r\n\r\n    ],<\/pre>\n<p>Then need to publish the configuration<\/p>\n<pre class=\"lang:default decode:true \">php artisan vendor:publish --tag=laravel-swoole\r\n\r\nCopied File [\/vendor\/swooletw\/laravel-swoole\/config\/swoole_http.php] To [\/config\/swoole_http.php]\r\nCopied File [\/vendor\/swooletw\/laravel-swoole\/config\/swoole_websocket.php] To [\/config\/swoole_websocket.php]\r\nCopied File [\/vendor\/swooletw\/laravel-swoole\/routes\/websocket.php] To [\/routes\/websocket.php]\r\nPublishing complete.<\/pre>\n<p>Then run the server :<\/p>\n<pre class=\"lang:default decode:true\">php artisan swoole:http start<\/pre>\n<p>open it on your browser: http:\/\/localhost:1215\/<\/p>\n<p>ANOTHER LARAVEL &#8211; SWOOLE IS<br \/>\nhttps:\/\/github.com\/hhxsv5\/laravel-s<br \/>\nI download for auction app from https:\/\/github.com\/GallopYD\/domain-spider<br \/>\nSTEPS:<\/p>\n<pre class=\"lang:default decode:true \">git clone https:\/\/github.com\/GallopYD\/domain-spider laravel-auction\r\n\r\ncd laravel-auction\r\n\r\ncomposer install<\/pre>\n<p>CREATE A .env file:<\/p>\n<pre class=\"lang:default decode:true\">APP_ENV=local\r\nAPP_DEBUG=true\r\nAPP_KEY=base64:CVSEtDyAtoBbQbZ5udq3vbrM8+URejsZSOFwqA7dBAE=\r\n\r\nDB_HOST=localhost\r\nDB_DATABASE=laravel_auction_swoole\r\nDB_USERNAME=root\r\nDB_PASSWORD=teddy\r\n\r\nCACHE_DRIVER=file\r\nSESSION_DRIVER=file<\/pre>\n<p>CREATE A NEW DATABASE &#8216;laravel_auction_swoole&#8217; COLLATION : utf8mb4_unicode_ci<br \/>\nRUN<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~\/Documents\/works\/swoole\/laravel-auction$ php artisan help -V\r\nLaravel Framework 5.6.39\r\n\r\nteddy@teddy:~\/Documents\/works\/swoole\/laravel-auction$ php artisan key:generate\r\nApplication key [base64:CVSEtDyAtoBbQbZ5udq3vbrM8+URejsZSOFwqA7dBAE=] set successfully.\r\n\r\nteddy@teddy:~\/Documents\/works\/swoole\/laravel-auction$ php artisan migrate --seedMigration table created successfully.\r\nMigrating: 2019_08_11_111354_create_domains_table\r\nMigrated:  2019_08_11_111354_create_domains_table<\/pre>\n<p>READ https:\/\/github.com\/hhxsv5\/laravel-s<br \/>\nPUBLISH<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~\/Documents\/works\/swoole\/laravel-auction$ php artisan laravels publish\r\n\r\n \/home\/teddy\/Documents\/works\/swoole\/laravel-auction\/config\/laravels.php already exists, do you want to override it ? Y\/N [N]:\r\n &gt; Y\r\n\r\nCopied 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]\r\nLinked file [\/home\/teddy\/Documents\/works\/swoole\/laravel-auction\/vendor\/hhxsv5\/laravel-s\/bin\/laravels] To [\/home\/teddy\/Documents\/works\/swoole\/laravel-auction\/bin\/laravels]\r\nLinked file [\/home\/teddy\/Documents\/works\/swoole\/laravel-auction\/vendor\/hhxsv5\/laravel-s\/bin\/fswatch] To [\/home\/teddy\/Documents\/works\/swoole\/laravel-auction\/bin\/fswatch]\r\nLinked file [\/home\/teddy\/Documents\/works\/swoole\/laravel-auction\/vendor\/hhxsv5\/laravel-s\/bin\/inotify] To [\/home\/teddy\/Documents\/works\/swoole\/laravel-auction\/bin\/inotify]<\/pre>\n<p>START SERVER<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~\/Documents\/works\/swoole\/laravel-auction$ php bin\/laravels start\r\n _                               _  _____ \r\n| |                             | |\/ ____|\r\n| |     __ _ _ __ __ ___   _____| | (___  \r\n| |    \/ _` | '__\/ _` \\ \\ \/ \/ _ \\ |\\___ \\ \r\n| |___| (_| | | | (_| |\\ V \/  __\/ |____) |\r\n|______\\__,_|_|  \\__,_| \\_\/ \\___|_|_____\/ \r\n                                           \r\nSpeed up your Laravel\/Lumen\r\n&gt;&gt;&gt; Components\r\n+---------------------------+--------------------------------------+\r\n| Component                 | Version                              |\r\n+---------------------------+--------------------------------------+\r\n| PHP                       | 7.3.9-1+ubuntu16.04.1+deb.sury.org+1 |\r\n| Swoole                    | 4.4.5                                |\r\n| LaravelS                  | 3.5.10                               |\r\n| Laravel Framework [local] | 5.6.39                               |\r\n+---------------------------+--------------------------------------+\r\n&gt;&gt;&gt; Protocols\r\n+-----------+--------+-------------------+----------------+\r\n| Protocol  | Status | Handler           | Listen At      |\r\n+-----------+--------+-------------------+----------------+\r\n| Main HTTP | On     | Laravel Framework | 127.0.0.1:5200 |\r\n+-----------+--------+-------------------+----------------+\r\n&gt;&gt;&gt; Feedback: https:\/\/github.com\/hhxsv5\/laravel-s\r\n[2019-09-21 16:54:46] [TRACE] Swoole is running, press Ctrl+C to quit.<\/pre>\n<p>OPEN IT ON THE BROWSER : http:\/\/localhost:5200\/<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ref: https:\/\/github.com\/huang-yi\/laravel-swoole-http My setting: 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 &nbsp; Create a laravel project. I tried version 6.x but I can&#8217;t use &#8216;laravel-swoole-http&#8217; so I installed version 5.6.x composer create-project &hellip; <a href=\"https:\/\/myprojects.advchaweb.com\/index.php\/2019\/09\/19\/laravel-and-swoole\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Laravel and Swoole&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82,48,104],"tags":[],"class_list":["post-4777","post","type-post","status-publish","format-standard","hentry","category-laravel-2","category-php-2","category-swoole"],"_links":{"self":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/4777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/comments?post=4777"}],"version-history":[{"count":6,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/4777\/revisions"}],"predecessor-version":[{"id":4799,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/4777\/revisions\/4799"}],"wp:attachment":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=4777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=4777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=4777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}