Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
igzard authored Jan 21, 2025
0 parents commit 30a2e6c
Show file tree
Hide file tree
Showing 12 changed files with 264 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: ✅ Tests

on: ['push', 'pull_request']

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: ['8.3']
dependency-version: [prefer-lowest, prefer-stable]

name: Tests P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}

steps:

- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, mbstring, zip
coverage: none

- name: Get Composer cache directory
id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer-${{ hashFiles('composer.json') }}
restore-keys: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer-

- name: Install Composer dependencies
run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist

- name: Unit Tests
run: php ./vendor/bin/phpunit --configuration phpunit.xml.dist
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/vendor/
/.idea/
composer.lock
phpunit.xml
.php-cs-fixer.cache
.phpunit.result.cache
21 changes: 21 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src');

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules(array(
'@PSR2' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP71Migration:risky' => true,
'ordered_imports' => true,
'strict_param' => true,
'strict_comparison' => true,
'array_syntax' => array('syntax' => 'short'),
'no_superfluous_phpdoc_tags' => true,
'blank_line_before_statement' => ['statements' => ['do', 'for', 'foreach', 'if', 'return', 'switch', 'try', 'while', 'yield']],
'header_comment' => ['comment_type' => 'comment', 'header' => ''],
))
->setFinder($finder);
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Gergely Ignácz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
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 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.
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.PHONY: help
.DEFAULT_GOAL := help

help:
@grep -h -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: composer-install
composer-install: ## install php packages
php ./vendor/bin/composer install

.PHONY: phpunit
phpunit: ## Run phpunit
php ./vendor/bin/phpunit --colors=always

.PHONY: php-cs-fixer
php-cs-fixer: ## Run php-cs-fixer
php ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --dry-run --verbose

.PHONY: php-cs-fixer-check
php-cs-fixer-check: ## Run php-cs-fixer-check
php ./vendor/bin/php-cs-fixer fix --dry-run

.PHONY: phpstan
phpstan: ## Run phpstan
php ./vendor/bin/phpstan

.PHONY: code-quality
code-quality: php-cs-fixer-check phpunit phpstan ## Run code quality checks
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# php-skeleton

🎉 This **Skeleton PHP** package created for your new package idea

<p align="center">
<p align="center">
<a href="https://github.com/igzard/php-skeleton/actions/workflows/tests.yml"><img src="https://img.shields.io/github/actions/workflow/status/igzard/php-skeleton/tests.yml?label=tests&style=flat-square" alt="Tests passed"></a>
<a href="https://packagist.org/packages/igzard/php-skeleton"><img alt="Total Downloads" src="https://img.shields.io/packagist/dt/igzard/php-skeleton"></a>
<a href="https://packagist.org/packages/igzard/php-skeleton"><img alt="Latest Version" src="https://img.shields.io/packagist/v/igzard/php-skeleton"></a>
</p>
</p>

------

> **Requires [PHP 8.3+](https://php.net/releases/)**
⚡️ Create your package using [Composer](https://getcomposer.org):

```bash
composer create-project igzard/php-skeleton --prefer-source PackageName
```

✅ Run **Code quality** check:
```bash
make code-quality
```

👷 Run **PHPUnit** tests:
```bash
make phpunit
```

🎨 Run **php-cs-fixer**:
```bash
make php-cs-fixer
```

🔥 Run **phpstan**:
```bash
make phpstan
```

🚀 Install dependencies with **composer**:
```bash
make composer-install
```

**Skeleton PHP** was created by **[Gergely Ignácz](https://x.com/igz4rd)** under the **[MIT license](https://opensource.org/licenses/MIT)**.
28 changes: 28 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "igzard/php-skeleton",
"description": "🎉 This skeleton PHP package created for your new package idea",
"type": "library",
"keywords": ["php", "skeleton", "package"],
"license": "MIT",
"autoload": {
"psr-4": {
"Igzard\\PhpSkeleton\\": "src/"
}
},
"authors": [
{
"name": "Gergely Ignácz",
"email": "[email protected]"
}
],
"require": {
"php": "^8.3.0"
},
"minimum-stability": "stable",
"prefer-stable": true,
"require-dev": {
"phpunit/phpunit": "^9",
"friendsofphp/php-cs-fixer": "^3.64",
"phpstan/phpstan": "^1.12"
}
}
13 changes: 13 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
parallel:
jobSize: 20
maximumNumberOfProcesses: 32
minimumNumberOfJobsPerProcess: 2
phpVersion: 80499
level: 5
paths:
- src
bootstrapFiles:
- vendor/autoload.php
reportUnmatchedIgnoredErrors: false
13 changes: 13 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
parallel:
jobSize: 20
maximumNumberOfProcesses: 32
minimumNumberOfJobsPerProcess: 2
phpVersion: 80499
level: 5
paths:
- src
bootstrapFiles:
- vendor/autoload.php
reportUnmatchedIgnoredErrors: false
13 changes: 13 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" defaultTestSuite="Unit" colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
13 changes: 13 additions & 0 deletions src/Example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Igzard\PhpSkeleton;

final class Example
{
public function hello(): string
{
return 'World';
}
}
15 changes: 15 additions & 0 deletions tests/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

use Igzard\PhpSkeleton\Example;
use PHPUnit\Framework\TestCase;

class ExampleTest extends TestCase
{
public function testHello(): void
{
$example = new Example();
$this->assertEquals('World', $example->hello());
}
}

0 comments on commit 30a2e6c

Please sign in to comment.