A project boilerplate of Slim Framework and Swoole an event-based asynchronous PHP extension.
Start your new project with composer:
$ composer create-project skoro/slim-swoole-project <project-path>Download or clone this project then cd into the project directory and build a container:
docker-compose build --no-cacheInstall dependencies and run the server:
docker-compose up -d
docker-compose exec php composer install
docker-compose exec php composer run serverThe default settings are good enough but if you need to customize them you have to start with copying stock settings:
$ cp .env.example .envThen you can start the http server by running this command:
$ composer run serverIt will listen to localhost and 9501 port if you left
SERVER_ADDR and SERVER_PORT environment variables by default.
When you need to stop or restart the server by an external command
like kill you also can use a pid file which is located in var/server.pid directory.
Please keep in mind, changing your project source code won't be
applied automatically, you need to restart the server manually.
To make life easier, you could enable DEBUG=true mode in your .env and the server
will restart automatically depending on the project source code
changes but this feature requires inotify extension to be installed.
Instead of editing your .env you could start the server like this:
$ composer run server-debugYou should also pay attention xdebug is not compatible with Swoole (https://openswoole.com/docs/get-started/common-install-errors#trying-to-use-xdebug-and-swoole).
This project uses PHP-DI container implementation.
The container itself and its dependencies are configured in config/container.php
file. Keep in mind, you can use any psr-11
compatible container, so it's up to you which container to use.