swoole-examples
swoole-examples copied to clipboard
Examples on how to use the Swoole async PHP framework
Swoole Example Projects
Examples on how to use the swoole async PHP framework
Examples Inside
serve-file: server a file using the correct mimetypeclient: make an async call to an external domain and download the pagechannel: share memory and data between coroutinesprocess: load an external program and run it multiple processesrouter: use an off-the-rack router (nikic/fast-route) to route request methods and URIswebsocket: a chat example with websocketsslim: an example of how to use the Slim Frameworkusers: using Swoole with Laravel with the laravel-swoole/wiki/Z1.-Noticesevent-source: an example of the EventSource long-lived connection
Installation
Take a look inside docker-compose.yml and uncomment the example you want to run.
composer installdocker-compose up
Installation for Laravel example
cd userscomposer installcp .env.example .env- Update
DB_CONNECTION=sqliteand comment out any otherDB_*lines touch database/database.sqlitephp artisan key:generatephp artisan migratephp artisan db:seed
Development
When modifying files, you need to restart the docker instance to see the changes. This is because the files are loaded into Swooles memory and therefore cannot be modified after the server is started. You may be familiar with this workflow if you developed anything using Node.js.