Skip to content
Merged
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
102 changes: 102 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Tests

on:
push:
branches: [ main, master, develop, laravel-12-implementation ]
pull_request:
branches: [ main, master, develop, laravel-12-implementation ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: [8.1, 8.2, 8.3]
laravel: [8.*, 9.*, 10.*, 11.*, 12.*]
dependency-version: [prefer-stable]
include:
- laravel: 8.*
testbench: ^6.0
phpunit: ^9.0
- laravel: 9.*
testbench: ^7.0
phpunit: ^9.0
- laravel: 10.*
testbench: ^8.0
phpunit: ^10.0
- laravel: 11.*
testbench: ^9.0
phpunit: ^10.0
- laravel: 12.*
testbench: ^10.0
phpunit: ^11.0
exclude:
# Laravel 8 requires PHP 8.0-8.1 (we'll allow 8.1 only)
- laravel: 8.*
php: 8.2
- laravel: 8.*
php: 8.3
# Laravel 9 requires PHP 8.0-8.2 (we'll allow 8.1-8.2)
- laravel: 9.*
php: 8.3
# Laravel 11 requires PHP 8.2+
- laravel: 11.*
php: 8.1
# Laravel 12 requires PHP 8.2+
- laravel: 12.*
php: 8.1

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl
coverage: xdebug

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-progress

- name: List Installed Dependencies
run: |
echo "Laravel Framework:"
composer show laravel/framework
echo "Orchestra Testbench:"
composer show orchestra/testbench
echo "PHPUnit:"
composer show phpunit/phpunit

- name: Execute tests
run: vendor/bin/phpunit --testdox --coverage-text

- name: Generate coverage report
if: matrix.php == '8.2' && matrix.laravel == '12.*'
run: vendor/bin/phpunit --coverage-clover=coverage.xml

- name: Upload coverage to Codecov
if: matrix.php == '8.2' && matrix.laravel == '12.*'
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
58 changes: 47 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,49 @@
build/
cache/
/bootstrap/compiled.php
/vendor
composer.phar
# Dependencies
/vendor/
/node_modules/

# Environment files
.env
.env.*
!.env.example

# Testing
/coverage/
.phpunit.cache/
.phpunit.result.cache

# Database files (for testing)
database/database.sqlite
*.sqlite
*.sqlite-journal
*.sqlite3

# IDE files
.idea/
.vscode/
*.sublime-project
*.sublime-workspace

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
/conf
.idea
/.settings
.env.*.php
.env.php
composer.lock

# Build artifacts
/build/
/dist/

# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Cache files
.php_cs.cache
.php_cs.cache.*
.php-cs-fixer.cache
79 changes: 79 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
FROM php:8.2-fpm

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip \
sqlite3 \
libsqlite3-dev \
libzip-dev \
libicu-dev \
libpq-dev \
libxpm-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libjpeg-dev \
libpng-dev \
libwebp-dev \
libxpm-dev \
libzip-dev \
libmagickwand-dev \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install -j$(nproc) \
bcmath \
exif \
gd \
intl \
mbstring \
opcache \
pdo \
pdo_mysql \
pdo_pgsql \
pdo_sqlite \
pcntl \
zip \
&& docker-php-source delete

# Install Xdebug for code coverage
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug

# Copy Xdebug configuration
COPY docker/php/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Set working directory
WORKDIR /var/www

# Copy existing application directory contents
COPY . /var/www

# Create necessary directories
RUN mkdir -p /var/www/storage/framework/{sessions,views,cache} \
&& mkdir -p /var/www/bootstrap/cache

# Set up the entry point
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

# Set up bash prompt
RUN echo 'export PS1="\[\e[32m\]\u@\h\[\e[0m\]:\[\e[34m\]\w\[\e[0m\] \$ "' >> /root/.bashrc

# Set permissions
RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache \
&& chmod -R 775 /var/www/storage /var/www/bootstrap/cache

# Set default command
CMD ["php-fpm"]
12 changes: 6 additions & 6 deletions LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)
MIT License

Copyright (c) <Scott Laurent>
Copyright (c) 2025 Scott Laurent

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
68 changes: 68 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.PHONY: up down build ssh composer test test-coverage test-phpunit install update help

# Project variables
DOCKER_COMPOSE = docker compose
DOCKER_COMPOSE_FILE = docker-compose.yml
DOCKER_SERVICE = app
COMPOSER = $(DOCKER_COMPOSE) run --rm $(DOCKER_SERVICE) composer

## —— Docker Compose ————————————————————————————————————————————————————————————
up: ## Start all containers in the background
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) up -d

up-verbose: ## Start all containers in the foreground
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) up

down: ## Stop and remove all containers
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) down

down-v: ## Stop and remove all containers and volumes
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) down -v

build: ## Rebuild the Docker containers
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) build --no-cache

ssh: up ## Get shell access to the container
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) exec $(DOCKER_SERVICE) bash

## —— Composer ——————————————————————————————————————————————————————————————————
composer: ## Run composer commands
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) run --rm $(DOCKER_SERVICE) composer $(filter-out $@,$(MAKECMDGOALS))

install: ## Install dependencies
@$(COMPOSER) install

update: ## Update dependencies
@$(COMPOSER) update

## —— Testing ———————————————————————————————————————————————————————————————————
test: ## Run all tests with coverage report
$(DOCKER_COMPOSE) run --rm $(DOCKER_SERVICE) bash -c "cd /var/www && XDEBUG_MODE=coverage ./vendor/bin/phpunit --testdox --coverage-text"

test-coverage: ## Generate HTML test coverage report
$(DOCKER_COMPOSE) run --rm $(DOCKER_SERVICE) bash -c "cd /var/www && XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html=coverage"

coverage: test-coverage ## Alias for test-coverage

open-coverage: test-coverage ## Open the coverage report in default browser
@if command -v xdg-open > /dev/null; then \
xdg-open coverage/index.html; \
elif command -v open > /dev/null; then \
open coverage/index.html; \
else \
echo "Please open coverage/index.html in your browser"; \
fi

test-phpunit: ## Run PHPUnit tests with optional arguments
$(DOCKER_COMPOSE) run --rm $(DOCKER_SERVICE) bash -c "cd /var/www && ./vendor/bin/phpunit $(filter-out $@,$(MAKECMDGOALS))"

## —— Help ——————————————————————————————————————————————————————————————————————
help: ## Display this help screen
@echo "\n\033[33mUsage:\033[0m\n make [command] [arguments...]\n"
@echo "\033[33mAvailable commands:\033[0m"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

.DEFAULT_GOAL := help

%:
@:
Loading