Skip to content

Commit

Permalink
Added petrenkoanton/php-collection package
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrenkoAnton committed Jan 11, 2024
1 parent a4c3341 commit 918ac62
Show file tree
Hide file tree
Showing 24 changed files with 294 additions and 185 deletions.
26 changes: 26 additions & 0 deletions .docker/php80/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM php:8.0-fpm

ARG user=docker

RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip

RUN apt-get clean && rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install mbstring exif pcntl bcmath gd

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN useradd -G www-data,root -u 1000 -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user

WORKDIR /var/www

USER $user
18 changes: 18 additions & 0 deletions .docker/php80/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.7"
services:
app:
build:
context: .
dockerfile: Dockerfile
image: php80-dto
container_name: php-dto
restart: unless-stopped
working_dir: /var/www/
volumes:
- ../../:/var/www
networks:
- default

networks:
default:
name: php-dto
26 changes: 26 additions & 0 deletions .docker/php81/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM php:8.1-fpm

ARG user=docker

RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip

RUN apt-get clean && rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install mbstring exif pcntl bcmath gd

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN useradd -G www-data,root -u 1000 -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user

WORKDIR /var/www

USER $user
18 changes: 18 additions & 0 deletions .docker/php81/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.7"
services:
app:
build:
context: .
dockerfile: Dockerfile
image: php81-dto
container_name: php-dto
restart: unless-stopped
working_dir: /var/www/
volumes:
- ../../:/var/www
networks:
- default

networks:
default:
name: php-dto
5 changes: 2 additions & 3 deletions Dockerfile → .docker/php82/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM php:8.2-fpm

ARG user
ARG uid
ARG user=docker

RUN apt-get update && apt-get install -y \
git \
Expand All @@ -18,7 +17,7 @@ RUN docker-php-ext-install mbstring exif pcntl bcmath gd

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN useradd -G www-data,root -u 1000 -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user

Expand Down
15 changes: 9 additions & 6 deletions docker-compose.yml → .docker/php82/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
version: "3.7"
services:
php:
app:
build:
args:
user: a
uid: 1000
context: .
dockerfile: Dockerfile
image: php82-dto
container_name: php82-dto
container_name: php-dto
restart: unless-stopped
working_dir: /var/www/
volumes:
- ./:/var/www
- ../../:/var/www
networks:
- default

networks:
default:
name: php-dto
26 changes: 26 additions & 0 deletions .docker/php83/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM php:8.3-fpm

ARG user=docker

RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip

RUN apt-get clean && rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install mbstring exif pcntl bcmath gd

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN useradd -G www-data,root -u 1000 -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user

WORKDIR /var/www

USER $user
18 changes: 18 additions & 0 deletions .docker/php83/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.7"
services:
app:
build:
context: .
dockerfile: Dockerfile
image: php83-dto
container_name: php-dto
restart: unless-stopped
working_dir: /var/www/
volumes:
- ../../:/var/www
networks:
- default

networks:
default:
name: php-dto
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: PHP Composer

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script test
44 changes: 36 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,49 @@
.DEFAULT_GOAL := inside

inside:
docker exec -it php82-dto /bin/bash
docker exec -it php-dto /bin/bash
.PHONY: inside

up:
docker-compose up -d
.PHONY: up
up80:
docker-compose -f .docker/php80/docker-compose.yml up -d
.PHONY: up80

up81:
docker-compose -f .docker/php81/docker-compose.yml up -d
.PHONY: up81

up82:
docker-compose -f .docker/php82/docker-compose.yml up -d
.PHONY: up82

up83:
docker-compose -f .docker/php83/docker-compose.yml up -d
.PHONY: up83

down:
docker-compose down
docker stop php-dto && docker rm php-dto
.PHONY: down

php-v:
docker exec -it php-dto php -v
.PHONY: php -v

v:
docker exec -it php-dto cat VERSION
.PHONY: v

test:
docker exec -it php-dto ./vendor/bin/phpunit
.PHONY: test

composer-test:
docker exec -it php-dto composer test
.PHONY: composer-test

test-ok:
docker exec -it php82-dto ./vendor/bin/phpunit --group ok
docker exec -it php-dto ./vendor/bin/phpunit --group ok
.PHONY: test-ok

test+:
docker exec -it php82-dto ./vendor/bin/phpunit --group +
.PHONY: +
docker exec -it php-dto ./vendor/bin/phpunit --group +
.PHONY: test+
18 changes: 13 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{
"name": "petrenkoanton/php82-dto",
"description": "",
"description": "Custom dto implementation",
"type": "library",
"keywords": ["dto", "structure"],
"minimum-stability": "stable",
"license": "proprietary",
"license": "MIT",
"authors": [
{
"name": "Anton Petrenko",
"email": "antptrnk@gmail.com"
"email": "antptrnk@gmail.com",
"homepage": "https://github.com/petrenkoanton",
"role": "Developer"
}
],
"require": {
"php": "^8.2"
"php": "^8.2",
"petrenkoanton/php-collection": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
Expand All @@ -24,5 +29,8 @@
"psr-4": {
"Tests\\": "tests"
}
},
"scripts": {
"test": "./vendor/bin/phpunit -c phpunit.xml"
}
}
}
54 changes: 52 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions src/Arrayable.php

This file was deleted.

9 changes: 0 additions & 9 deletions src/Collectable.php

This file was deleted.

Loading

0 comments on commit 918ac62

Please sign in to comment.