Yii2 console application used to write our processors of methods to responsible to client calling.

Overview

Microservice Application Skeleton

Yii2 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 yii_dev user-service/listen

For sending tests messages, By using this client library (jafaripur/php-microservice-user-service):

php yii_dev user-service/send-test

Create project

composer create-project "jafaripur/php-microservice-application-yii2 dev-master" micro3

Configuration

Three env file exist:


.env        => For production
.env_dev    => For development
.env_test   => For test with codeception

Three entrypoint:


yii        => For production
yii_dev    => For development
yii_test   => For test with codeception

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 yii user-service/listen first-consumer"
    process_num: 10
    exec_timeout: 0
    remain_after_exit: true
    restart_sec: 5

  emits:
    command: "php yii 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

# Run test
docker-compose up --build micro

# Stop and remove created containers
docker-compose down
You might also like...
Date/Time Picker widget for Yii2 framework Based on Eonasdan's Bootstrap 3 Date/Time Picker
Date/Time Picker widget for Yii2 framework Based on Eonasdan's Bootstrap 3 Date/Time Picker

Yii2 Date/Time Picker Widget Date/Time Picker widget for Yii2 framework Based on Eonasdan's Bootstrap 3 Date/Time Picker Demo Since this is a part of

Yii2 extension for format inputs based on AutoNumeric.js

Yii2 extension for format inputs based on AutoNumeric.js

Yii2 SwitchInput widget turns checkboxes and radio buttons into toggle switchinputes

Yii2 SwitchInput widget turns checkboxes and radio buttons into toggle switchinputes

An enhanced FileInput widget for Bootstrap 4.x/3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)
An enhanced FileInput widget for Bootstrap 4.x/3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)

yii2-widget-fileinput The FileInput widget is a customized file input widget based on Krajee's Bootstrap FileInput JQuery Plugin. The widget enhances

An enhanced Yii 2 widget encapsulating the HTML 5 range input (sub repo split from yii2-widgets)
An enhanced Yii 2 widget encapsulating the HTML 5 range input (sub repo split from yii2-widgets)

yii2-widget-rangeinput The RangeInput widget is a customized range slider control widget based on HTML5 range input. The widget enhances the default H

A Yii2 module for embedding social plugins and widgets.
A Yii2 module for embedding social plugins and widgets.

yii2-social Module that enables access to social plugins for Yii Framework 2.0. It includes support for embedding plugins from the following networks

Pug Yii2 adapter

Yii 2 Pug (ex Jade) extension This extension provides a view renderer for Pug templates for Yii framework 2.0 applications. Support GutHub issues Inst

This is Yii2 utilities

YII2-UTILITY This is Yii2 utilities. Requirements PHP = 7.4 Curl extension for PHP7 must be enabled. Download Using Composer From your project direct

Alejandro Flores, Php Yii2 Emoac

Prueba Tecnica Emoac Proyecto basado en PHP con Yii2. Hecho por Alejandro Flores, Ingeniero en informática. Este proyecto consta de un CRUD de product

Comments
  • Bump friendsofphp/php-cs-fixer from 3.5.0 to 3.6.0

    Bump friendsofphp/php-cs-fixer from 3.5.0 to 3.6.0

    Bumps friendsofphp/php-cs-fixer from 3.5.0 to 3.6.0.

    Release notes

    Sourced from friendsofphp/php-cs-fixer's releases.

    v3.6.0 Roe Deer

    • bug #6063 PhpdocTypesOrderFixer - Improve nested types support (ruudk, julienfalque)
    • bug #6197 FullyQualifiedStrictTypesFixer - fix same classname is imported from … (SpacePossum)
    • bug #6241 NoSuperfluousPhpdocTagsFixer - fix for reference and splat operator (kubawerlos)
    • bug #6243 PhpdocTypesOrderFixer - fix for intersection types (kubawerlos)
    • bug #6254 PhpUnitDedicateAssertFixer - remove is_resource. (drupol)
    • bug #6264 TokensAnalyzer - fix isConstantInvocation detection for mulitple exce… (SpacePossum)
    • bug #6265 NullableTypeDeclarationForDefaultNullValueFixer - handle "readonly" a… (SpacePossum)
    • bug #6266 SimplifiedIfReturnFixer - handle statement in loop without braces (SpacePossum)
    • feature #6262 ClassReferenceNameCasingFixer - introduction (SpacePossum)
    • feature #6267 NoUnneededImportAliasFixer - Introduction (SpacePossum)
    • minor #6199 HeaderCommentFixer - support monolithic files with shebang (kubawerlos, keradus)
    • minor #6231 Fix priority descriptions and tests. (SpacePossum)
    • minor #6237 DX: Application - better display version when displaying gitSha (keradus)
    • minor #6242 Annotation - improve on recognising types with reference and splat operator (kubawerlos)
    • minor #6250 Tokens - optimize cache clear (SpacePossum)
    • minor #6269 Docs: redo warnings in RST docs to fix issue on website docs (keradus)
    • minor #6270 ClassReferenceNameCasingFixer - Add missing test cases for catch (SpacePossum)
    • minor #6273 Add priority test (SpacePossum)
    Changelog

    Sourced from friendsofphp/php-cs-fixer's changelog.

    Changelog for v3.6.0

    • bug #6063 PhpdocTypesOrderFixer - Improve nested types support (ruudk, julienfalque)
    • bug #6197 FullyQualifiedStrictTypesFixer - fix same classname is imported from … (SpacePossum)
    • bug #6241 NoSuperfluousPhpdocTagsFixer - fix for reference and splat operator (kubawerlos)
    • bug #6243 PhpdocTypesOrderFixer - fix for intersection types (kubawerlos)
    • bug #6254 PhpUnitDedicateAssertFixer - remove is_resource. (drupol)
    • bug #6264 TokensAnalyzer - fix isConstantInvocation detection for mulitple exce… (SpacePossum)
    • bug #6265 NullableTypeDeclarationForDefaultNullValueFixer - handle "readonly" a… (SpacePossum)
    • bug #6266 SimplifiedIfReturnFixer - handle statement in loop without braces (SpacePossum)
    • feature #6262 ClassReferenceNameCasingFixer - introduction (SpacePossum)
    • feature #6267 NoUnneededImportAliasFixer - Introduction (SpacePossum)
    • minor #6199 HeaderCommentFixer - support monolithic files with shebang (kubawerlos, keradus)
    • minor #6231 Fix priority descriptions and tests. (SpacePossum)
    • minor #6237 DX: Application - better display version when displaying gitSha (keradus)
    • minor #6242 Annotation - improve on recognising types with reference and splat operator (kubawerlos)
    • minor #6250 Tokens - optimize cache clear (SpacePossum)
    • minor #6269 Docs: redo warnings in RST docs to fix issue on website docs (keradus)
    • minor #6270 ClassReferenceNameCasingFixer - Add missing test cases for catch (SpacePossum)
    • minor #6273 Add priority test (SpacePossum)
    Commits
    • 1975e44 prepared the 3.6.0 release
    • db4b997 minor #6273 Add priority test (SpacePossum)
    • 7bdb9a2 Add priority test
    • a6fa961 minor #6270 ClassReferenceNameCasingFixer - Add missing test cases for catch ...
    • 9e31f1f ClassReferenceNameCasingFixer - Add missing test cases for catch
    • 42a449a minor #6269 Docs: redo warnings in RST docs to fix issue on website docs (ker...
    • f1a0942 Docs: redo warnings in RST docs to fix issue on website docs
    • 86d0a4c feature #6262 ClassReferenceNameCasingFixer - introduction (SpacePossum)
    • 776850a ClassReferenceNameCasingFixer - introduction
    • 248a56b feature #6267 NoUnneededImportAliasFixer - Introduction (SpacePossum)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • Bump codeception/specify from 0.4.6 to 2.0.0

    Bump codeception/specify from 0.4.6 to 2.0.0

    Bumps codeception/specify from 0.4.6 to 2.0.0.

    Release notes

    Sourced from codeception/specify's releases.

    2.0.0

    What's Changed

    Full Changelog: https://github.com/Codeception/Specify/compare/1.4.0...2.0.0

    1.4.0

    • Added Fluent Interface support, this allows you to add it's and should's chained to a specify or describe.
    • Specify.php trait now only has the public API methods.
    • If an it or should only receives text now that test is marked as incomplete.
    • shouldNot and its were added as aliases.

    PHPUnit 9 support

    No release notes provided.

    PHPUnit 8 support

    • Extended range of supported PHPUnit versions to include PHPUnit 8
    • Fixed signature of result printer `writeProcess method #45 by @​purwandi

    PHPUnit 7 supprt / PHPUnit 6.x drop

    Due to interface change in PHPUnit 7 we can't support both PHPUnit 7x. and 6.x This release request PHPUnit 7.x and PHP 7.1+ as well.

    If you can't update keep using 1.0 version.

    1.0

    Specify was refactored to simplify its usage. Works with PHP7 and PHPUnit 6+ only (and Codeception, of course)

    • BREAKING: PHPUnit 6 support
    • BREAKING: Removed configuration section
    • BREAKING: Only properties marked with @specify annotation are cloned in specify blocks.
    • BREAKING: Removed throws parameter in specify blocks
    • Added $this->describe, $this->it, $this->should aliases to $this->specify
    • Added Codeception\Specify\ResultPrinter to fix printing progress of specify blocks.

    Upgrade Plan

    1. Update to PHP7+ PHPUnit 6+
    2. Add to phpunit.xml: printerClass="Codeception\Specify\ResultPrinter"
    3. If relied on property cloning, add @specify annotation for all properties which needs to be cloned for specify blocks
    4. If you used throws parameter, consider using AssertThrows package.
    Changelog

    Sourced from codeception/specify's changelog.

    Changelog

    1.5

    • Removed support for PHP 7.1 and PHP 7.2.
    • Use strict types in the source code.

    1.4

    • Added Fluent Interface support, this allows you to add it's and should's chained to a specify or describe.
    • Specify.php trait now only has the public API methods.
    • If an it or should only receives text now that test is marked as incomplete.
    • shouldNot and its were added as aliases.
    • Added .phpunit.result.cache file to .gitignore
    • Updated README.md

    1.0

    • BREAKING: PHPUnit 6 support
    • BREAKING: Removed configuration section
    • BREAKING: Only properties marked with @specify annotation are cloned in specify blocks.
    • BREAKING: Removed throws parameter in specify blocks
    • Added Codeception\Specify\ResultPrinter to fix printing progress of specify blocks.

    Upgrade Plan

    1. Update to PHP7+ PHPUnit 6+
    2. Add to phpunit.xml: printerClass="Codeception\Specify\ResultPrinter"
    3. If relied on property cloning, add @specify annotation for all properties which needs to be cloned for specify blocks
    4. If you used throws parameter, consider using AssertThrows package.

    0.4.3

    • Show example index on failure by @​zszucs 2015-11-27

    0.4.2

    0.4.0

    • Fixes cloning properties in examples. Issue #6 2014-10-15
    • Added global and local specify configs, for disabling cloning properties and changing cloning methods 2014-10-15

    0.3.6

    03/22/2014

    • Cloning unclonnable items

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • Bump codeception/module-asserts from 1.3.1 to 2.0.1

    Bump codeception/module-asserts from 1.3.1 to 2.0.1

    Bumps codeception/module-asserts from 1.3.1 to 2.0.1.

    Release notes

    Sourced from codeception/module-asserts's releases.

    2.0.1

    What's Changed

    2.0.0

    What's Changed

    Full Changelog: https://github.com/Codeception/module-asserts/compare/1.3.1...2.0.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
Owner
Jafaripur
Jafaripur
Simple RBAC Manager for Yii2 (minify of yii2-admin)

Yii2 Mimin Simple RBAC Manager fo Yii 2.0. Minify of yii2-admin extension with awesome features Attention Before you install and use this extension, t

Hafid Mukhlasin 52 Sep 22, 2022
This package provides some basic methods to implement a self updating functionality for your Laravel application. Already bundled are some methods to provide a self-update mechanism via Github or some private repository via http.

This package provides some basic methods to implement a self updating functionality for your Laravel 5 application. Already bundled are some methods to provide a self-update mechanism via Github.

Holger Lösken 311 Dec 31, 2022
PHP Kafka client is used in PHP-FPM and Swoole. PHP Kafka client supports 50 APIs, which might be one that supports the most message types ever.

longlang/phpkafka Introduction English | 简体中文 PHP Kafka client is used in PHP-FPM and Swoole. The communication protocol is based on the JSON file in

Swoole Project 235 Dec 31, 2022
A set of ready-made regex helper methods for use in your Laravel application.

Regex A set of ready-made regex helper methods for use in your Laravel application. Installation composer require hotmeteor/regex Usage Regex comes wi

Adam Campbell 229 Dec 25, 2022
A easy way to install your basic yii projetc, we have encrypt database password in phpfile, my class with alot funtions to help you encrypt and decrypt and our swoole server install just run ./yii swoole/start and be happy!

Yii 2 Basic Project Template with swoole and Modules Yii 2 Basic Project Template is a skeleton Yii 2 application best for rapidly creating small proj

null 3 Apr 11, 2022
Tarantool connector for yii2 framework. Allow to use activerecord, schemas, widgets and more.

Tarantool connector for yii2 framework Tarantool connector for yii2 framework. Allow to use framework abstractions such as ActiveRecord, Schema, Table

Andrey 11 Nov 21, 2021
Web Push Notifications brought to Yii2

Web Push Notifications for Yii 2 An extension for implementing Web Push Notifications on your website in a breeze. Documentation is at docs/README.md

Mehdi Achour 12 May 19, 2022
yii2-app-advanced with Twitter Bootstrap 5

Yii 2 Advanced Project Template is a skeleton Yii 2 application best for developing complex Web applications with multiple tiers.

Nedarta 1 Nov 5, 2021
Prometheus exporter for Yii2

yii2-prometheus Prometheus Extension for Yii 2 This extension provides a Prometheus exporter component for Yii framework 2.0 applications. This extens

Mehdi Achour 3 Oct 27, 2021
Yii2-symfonymailer - Yii 2 Symfony mailer extension.

Yii Mailer Library - Symfony Mailer Extension This extension provides a Symfony Mailer mail solution for Yii framework 2.0. For license information ch

Yii Software 28 Dec 22, 2022