jafaripur / php-microservice-application-symfony
php-microservice skeleton console application starter with Symfony for microservice node
Installs: 0
Dependents: 0
Suggesters: 1
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.1
- ext-ctype: *
- ext-iconv: *
- jafaripur/php-microservice: dev-master
- jafaripur/php-microservice-user-service: dev-master
- spiral/roadrunner: ^2.7
- symfony/console: 6.0.*
- symfony/dotenv: 6.0.*
- symfony/flex: ^2
- symfony/framework-bundle: 6.0.*
- symfony/http-client: 6.0.*
- symfony/runtime: 6.0.*
- symfony/yaml: 6.0.*
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.7
- overtrue/phplint: ^4.0
- phpunit/phpunit: ^9.5
- symfony/browser-kit: 6.0.*
- symfony/css-selector: 6.0.*
- symfony/phpunit-bridge: ^6.0
- vimeo/psalm: ^4.22
Conflicts
This package is auto-updated.
Last update: 2024-11-14 20:22:14 UTC
README
Symfony
console application used to write our processors of methods to responsible to client calling.
This application a template for microservice application and implement four methods of jafaripur/php-microservice. Another library created for using this microservice methods jafaripur/php-microservice-user-service.
For consuming and receiving data:
php bin/console user-service:listen
For sending tests messages, By using this client library (jafaripur/php-microservice-user-service
):
php bin/console user-service:send-test
Create project
composer create-project "jafaripur/php-microservice-application-symfony dev-master" micro3
Production Build
This application can be run with roadrunner
service plugin in production with Dockerfile docker/Dockerfile.prod
, Production build with docker:
export DOCKER_BUILDKIT=1 && docker build -f "./docker/Dockerfile.prod" -t "micro3-prod:latest" .
After building, we can create a container or docker swarm service. The production docker image runs with RoadRunner
. In this example we use this configuration for RoadRunner, config exist in .rr.yaml
file.
version: "2.7" service: topics: command: "php bin/console user-service:listen first-consumer" process_num: 10 exec_timeout: 0 remain_after_exit: true restart_sec: 5 emits: command: "php bin/console user-service:listen second-consumer" process_num: 2 exec_timeout: 0 remain_after_exit: true restart_sec: 5 logs: mode: production encoding: console
With this RoadRunner service plugin we can run several consumer with several instance.
For creating docker container from builded image:
docker run -d --init \ --name micro3-container \ --restart unless-stopped \ micro3-prod:latest
And for swarm service:
docker service create --name "micro3-service" \
--replicas 2 \
--update-delay 10s \
micro3-prod:latest
Test
# Build test containers docker-compose build --build-arg APP_SECRET=123456 # Run test docker-compose up micro # Stop and remove created containers docker-compose down