build: add a PHP environment

This commit is contained in:
Oliver Davies 2022-09-27 14:22:00 +01:00
parent 4e2e0d6f0c
commit 6c967e7fa4
9 changed files with 2937 additions and 0 deletions

2
php/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/.phpunit.result.cache
/vendor/

20
php/Dockerfile Normal file
View file

@ -0,0 +1,20 @@
FROM php:8.1-cli-bullseye
ENV PATH=$PATH:/app/vendor/bin
COPY --from=composer /usr/bin/composer /usr/bin/composer
WORKDIR /app
RUN apt-get update -yqq \
&& apt-get install -yqq git unzip \
&& adduser --disabled-password app \
&& chown app:app -R /app
USER app
COPY --chown=app:app composer.* ./
RUN composer install
COPY --chown=app:app . .

11
php/composer.json Normal file
View file

@ -0,0 +1,11 @@
{
"require-dev": {
"phpunit/phpunit": "^9.5",
"pestphp/pest": "^1.22"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
}
}

2859
php/composer.lock generated Normal file

File diff suppressed because it is too large Load diff

6
php/docker-compose.yaml Normal file
View file

@ -0,0 +1,6 @@
services:
php:
build: .
volumes:
- ./:/app
command: "bash"

16
php/justfile Normal file
View file

@ -0,0 +1,16 @@
# List all recipes.
default:
just --list
# Run a Composer command.
composer *args:
docker compose run --rm -it php composer {{ args }}
# Run tests with Pest.
test *args:
clear
docker compose run --rm -it php pest {{ args }}
# Run tests with Pest and watch for changes.
test-watch *args:
find src tests -type f | entr just test {{ args }}

18
php/phpunit.xml Normal file
View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</phpunit>

0
php/src/.keep Normal file
View file

View file

@ -0,0 +1,5 @@
<?php
it('should return true', function () {
expect(false)->toBeTrue();
});