Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/james2doyle/swoole-examples
Examples on how to use the Swoole async PHP framework
https://github.com/james2doyle/swoole-examples
async coroutine php websocket
Last synced: 10 days ago
JSON representation
Examples on how to use the Swoole async PHP framework
- Host: GitHub
- URL: https://github.com/james2doyle/swoole-examples
- Owner: james2doyle
- License: mit
- Created: 2018-05-16T04:28:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T03:38:25.000Z (over 1 year ago)
- Last Synced: 2024-04-14T14:57:26.267Z (7 months ago)
- Topics: async, coroutine, php, websocket
- Language: PHP
- Size: 783 KB
- Stars: 68
- Watchers: 6
- Forks: 6
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Swoole Example Projects
=========================> Examples on how to use the [swoole async PHP framework](https://www.swoole.co.uk/)
### Examples Inside
* `serve-file`: server a file using the correct mimetype
* `client`: make an async call to an external domain and download the page
* `channel`: share memory and data between coroutines
* `process`: load an external program and run it multiple processes
* `router`: use an off-the-rack router ([nikic/fast-route](https://github.com/nikic/FastRoute)) to route request methods and URIs
* `websocket`: a chat example with websockets
* `slim`: an example of how to use the [Slim Framework](https://www.slimframework.com/)
* `users`: using Swoole with Laravel with the [laravel-swoole/wiki/Z1.-Notices](https://github.com/swooletw/laravel-swoole/)
* `event-source`: an example of the [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) long-lived connection### Installation
Take a look inside `docker-compose.yml` and uncomment the example you want to run.
* `composer install`
* `docker-compose up`#### Installation for Laravel example
* `cd users`
* `composer install`
* `cp .env.example .env`
* Update `DB_CONNECTION=sqlite` and comment out any other `DB_*` lines
* `touch database/database.sqlite`
* `php artisan key:generate`
* `php artisan migrate`
* `php 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.