Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1 - 8.3 + Docker + Github Actions + Refactoring of the code #219

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Test Pipeline"

on:
pull_request:
push:
branches:
- "master"

jobs:
tests:
name: "Run Tests"
runs-on: "ubuntu-latest"
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr

- name: "Cache dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "EasyCodingStandards for src"
run: "vendor/bin/ecs check src/ tests/ --no-interaction --no-progress-bar"

- name: "PhpStan for src/"
run: "vendor/bin/phpstan analyse --error-format=checkstyle src --level=8 | cs2pr"

- name: "PhpStan for tests/"
run: "vendor/bin/phpstan analyse --error-format=checkstyle tests/ --level=6 | cs2pr"

- name: "PHPUnit Test with Coverage"
run: "vendor/bin/phpunit -c phpunit.xml.dist tests/ --coverage-clover=clover.xml"

# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v3
# with:
# file: src/clover.xml
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
composer.lock
vendor
.idea/
.phpunit.result.cache
.phpunit.result.cache
.phpunit.cache
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ $vcard->addRole('Data Protection Officer');
$vcard->addEmail('[email protected]');
$vcard->addPhoneNumber(1234121212, 'PREF;WORK');
$vcard->addPhoneNumber(123456789, 'WORK');
$vcard->addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium');
$vcard->addAddress('', '', 'street', 'worktown', '', 'workpostcode', 'Belgium');
$vcard->addLabel('street, worktown, workpostcode Belgium');
$vcard->addURL('http://www.jeroendesloovere.be');
$vcard->addURL('https://www.wikipedia.de');

$vcard->addPhoto(__DIR__ . '/landscape.jpeg');

Expand All @@ -60,7 +60,7 @@ return $vcard->download();

```

> [View all examples](/examples/example.php) or check [the VCard class](/src/VCard.php).
> [View all examples](/examples/example.php) or check [the VCard class](/src_/VCard.php).

### Parsing examples

Expand All @@ -78,9 +78,9 @@ Or by using a factory method with a file name:

```php
$parser = VCardParser::parseFromFile('path/to/file.vcf');
echo $parser->getCardAtIndex(0)->fullname; // Prints the full name.
echo $parser->getCardAtIndex(0)->getName(); // Prints the full name.
```
> [View the parsing example](/examples/example_parsing.php) or check the [the VCardParser class](/src/VCardParser.php) class.
> [View the parsing example](/examples/example_parsing.php) or check the [the VCardParser class](/src_/VCardParser.php) class.

**Support for frameworks**

Expand Down Expand Up @@ -127,6 +127,16 @@ Contributions are **welcome** and will be fully **credited**.

More info on how to work with GitHub on help.github.com.

### Development

In order to run the development instance of this repository, you can very easily utilize the shipped docker-compose package.

```bash
docker compose up --build
```

Afterwards you will have an instance with PHP8.3 running that you can use to develop your changes. Xdebug is enabled by default, so you can use your IDE to debug the code.

## Credits

- [Jeroen Desloovere](https://github.com/jeroendesloovere)
Expand Down
17 changes: 17 additions & 0 deletions build/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM php:8.2-cli

ENV PHP_IDE_CONFIG="serverName=vcard"
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug

ADD ./etc/php.ini /usr/local/etc/php/php.ini
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

RUN apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
&& docker-php-ext-install zip

WORKDIR /var/www/html
CMD ["tail", "-f", "/dev/stdout"]
25 changes: 25 additions & 0 deletions build/php/etc/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
magic_quotes_gpc = Off;
register_globals = Off;
file_uploads = On;
default_charset = UTF-8;
memory_limit = 4G;
max_execution_time = 36000;
upload_max_filesize = 999M;
post_max_size = 999M;
safe_mode = Off;
mysql.connect_timeout = 20;
allow_url_fopen = true;
display_errors = 1;
error_reporting = E_ALL;
date.timezone = "Europe/Berlin"

xdebug.idekey=PHPSTORM
xdebug.max_nesting_level = 2048
xdebug.mode=develop,debug,coverage
xdebug.client_port=9000
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
xdebug.discover_client_host=0
xdebug.show_error_trace=1

pm.max_children = 25
23 changes: 18 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,32 @@
"email": "[email protected]",
"homepage": "http://jeroendesloovere.be",
"role": "Developer"
},
{
"name": "Maximilian Graf Schimmelmann",
"email": "[email protected]",
"homepage": "https://www.schimmelmann.org",
"role": "Developer"
}
],
"require": {
"php": ">=7.3.0",
"behat/transliterator": "~1.0"
"php": "^8.1",
"behat/transliterator": "~1.0",
"webmozart/assert": "^1.11",
"ext-fileinfo": "*",
"ext-curl": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
"phpunit/phpunit": "^10",
"symplify/easy-coding-standard": "^12.1",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-webmozart-assert": "^1.2",
"seec/phpunit-consecutive-params": "^1.1"
},
"autoload": {
"psr-4": { "JeroenDesloovere\\VCard\\": "src/" }
"psr-4": { "JeroenDesloovere\\VCard\\": "src/"}
},
"autoload-dev": {
"psr-4": { "JeroenDesloovere\\VCard\\": "tests/" }
"psr-4": { "JeroenDesloovere\\VCard\\Tests\\": "tests/"}
}
}
7 changes: 7 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '3.9'

services:
php:
build: ./build/php
volumes:
- .:/var/www/html
Loading