Skip to content

Commit

Permalink
first domain events class
Browse files Browse the repository at this point in the history
  • Loading branch information
frederic100 committed Sep 23, 2023
1 parent 07c7237 commit 1bdb026
Show file tree
Hide file tree
Showing 23 changed files with 4,467 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/var/
/vendor/
/.phpunit.cache/
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
# Installation

composer require ddd/event
composer require ddd/event

# Usage

Steps are:
* create a domain event (name + past tense verb, example: AccountCreated implements DomainEventInterface)
* publish this event
* distribute events

Somewhere else:
* create a subscriber at an event (exemple: class SendEmailWhenAccountCreatedSubscriber implements DomainEventSubscriber)
* register the subscriber, when event will be distrute the subscriber will handle it and do what it has to do

# To Contribut to ddd/Event

## Requirements

* docker
* git

## Install

* git clone [email protected]:frederic100/event.git

## Unit test

```console
bin/phpunit
```

with Test Developpment Driven (thanks Kent Beck and the others), good practices (thanks R.Martin and the others)

## Quality

* phpcs STD12
* phpstan level 9
* coverage 100%
* infection MSI >99%

Quick check with:
```console
./codecheck
```

Check coverage with:
```console
bin/phpunit --coverage-html var
```
and view 'var/index.html' with your browser

Check infection with:
```console
bin/infection
```
and view 'var/infection.html' with your browser
14 changes: 14 additions & 0 deletions bin/composer
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
echo ${COMPOSER_HOME:-$HOME/.composer}
if [ -t 0 ] ; then
moinsit='-it'
else
moinsit=''
fi
docker run ${moinsit} --rm \
--volume $PWD:/app \
--user 1000:1000 \
-ti \
--name composer-running-script \
-v "$PWD":/usr/src \
composer-nextsign composer $@
20 changes: 20 additions & 0 deletions bin/docker/composer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM composer:2.5.5

# Install necessary dependencies
RUN apk update \
&& apk add --no-cache \
git \
unzip \
rabbitmq-c-dev \
g++ \
make \
autoconf

# Install the PHP AMQP extension
RUN pecl install amqp \
&& docker-php-ext-enable amqp

WORKDIR /usr/src



9 changes: 9 additions & 0 deletions bin/docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM php:8.2.10-fpm

# Installation de l'extension pecl pcov
RUN pecl install pcov \
&& docker-php-ext-enable pcov

COPY ./php.ini $PHP_INI_DIR/php.ini

WORKDIR /usr/src
4 changes: 4 additions & 0 deletions bin/docker/php/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
date.timezone=Europe/Paris
memory_limit=-1
phar.readonly=0
pcov.enabled=1
3 changes: 3 additions & 0 deletions bin/infection
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

bin/php vendor/bin/infection --threads=$(nproc) $@
12 changes: 12 additions & 0 deletions bin/php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

docker run \
--init \
--rm \
-ti \
--name php-ddd-event-running-script \
-v "$(pwd)/bin/docker/php/php.ini:/usr/local/etc/php/php.ini" \
-v "$PWD":"$PWD" \
--user 1000:1000 \
-w "$PWD" \
php-ddd-event php $@
3 changes: 3 additions & 0 deletions bin/phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

bin/php vendor/bin/phpunit $@
11 changes: 11 additions & 0 deletions codecheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

#bin/local-php-security-checker composer.lock

bin/php vendor/bin/phpcbf --standard=PSR12 ./src ./tests
bin/php vendor/bin/phpcs --standard=PSR12 ./src ./tests

bin/php vendor/bin/phpstan analyse --level=9 ./src
bin/php vendor/bin/phpstan analyse --level=9 ./tests

bin/phpunit --testsuite all
43 changes: 43 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "dddphp/event",
"type": "library",
"description": "To implement events in domain driven developement or anyother styles projects with PHP",
"keywords": ["templating"],
"homepage": "https://github.com/frederic100/event",
"license": "BSD-3-Clause",
"minimum-stability": "dev",
"authors": [
{
"name": "Frédéric Royet",
"email": "[email protected]",
"homepage": "https://www.linkedin.com/in/frederic-royet-42568566/",
"role": "Project Founder"
}
],
"require": {
"php": ">=7.2.5"
},
"require-dev": {
"infection/extension-installer": "0.1.2",
"infection/infection": "^0.27",
"phpstan/phpdoc-parser": "^1.20",
"phpstan/phpstan": "1.10.15",
"phpunit/phpunit": "^10",
"squizlabs/php_codesniffer": "3.*"
},
"autoload": {
"psr-4" : {
"Ddd\\Event\\" : "src/"
}
},
"autoload-dev": {
"psr-4" : {
"Ddd\\Event\\Tests\\" : "tests/"
}
},
"config": {
"allow-plugins": {
"infection/extension-installer": true
}
}
}
Loading

0 comments on commit 1bdb026

Please sign in to comment.