Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
terremoth committed Mar 3, 2024
1 parent fc245e7 commit 60a5e97
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4

[{*.yml, *.yaml}]
indent_size = 2
58 changes: 58 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Complete Workflow

on: [ push, pull_request ]

jobs:
run:
runs-on: ubuntu-latest

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
# coverage: none

- name: Setup Composer
uses: php-actions/composer@v6

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}

# - name: Run composer install
# run: composer install -n --prefer-dist

- name: Run psalm
run: ./vendor/bin/psalm --shepherd --threads=2 --no-cache --output-format=github

- name: PHPUnit Tests
uses: php-actions/phpunit@v3
env:
XDEBUG_MODE: coverage
with:
bootstrap: vendor/autoload.php
configuration: phpunit.xml
php_extensions: xdebug
args: tests --coverage-clover ./coverage.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1
with:
files: ./coverage.xml
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: PHP Mess Detector
uses: php-actions/phpmd@v1
with:
php_version: 8.1
path: src/,demos/,tests/
output: text
ruleset: phpmd.xml
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
# php-project-template
My personal PHP projects template
My personal PHP projects template

Change the "vendor" word to the correct repo vendor name

[![CodeCov](https://codecov.io/gh/terremoth/vendor/graph/badge.svg?token=TOKEN)](https://app.codecov.io/gh/terremoth/vendor)
[![Psalm type coverage](https://shepherd.dev/github/terremoth/vendor/coverage.svg)](https://shepherd.dev/github/terremoth/vendor)
[![Psalm level](https://shepherd.dev/github/terremoth/vendor/level.svg)](https://shepherd.dev/github/terremoth/vendor)
[![Test Run Status](https://github.com/terremoth/vendor/actions/workflows/workflow.yml/badge.svg?branch=main)](https://github.com/terremoth/vendor/actions/workflows/workflow.yml)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f77e487ba22943b5b199a2567f44d6af)](https://app.codacy.com/gh/terremoth/vendor/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/0b0046e370496f58fa6e/maintainability)](https://codeclimate.com/github/terremoth/vendor/maintainability)
[![License](https://img.shields.io/github/license/terremoth/vendor.svg?logo=gnu&color=41bb13)](https://github.com/terremoth/vendor/blob/main/LICENSE)

See [demos/demo.php](demos/demo.php) for examples.

## Installation

- Clone this repo:
- `$ git clone ...`
56 changes: 56 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "terremoth/",
"description": "",
"type": "library",
"require": {
"php": "^8.1"
},
"keywords": [
"project-template",
],
"require-dev": {
"phpunit/phpunit": "^10.0",
"vimeo/psalm": "^5.0",
"nikic/php-parser": "^4.10",
"squizlabs/php_codesniffer": "*",
"phpmd/phpmd": "@stable"
},
"license": "GPL-3.0-or-later",
"autoload": {
"psr-4": {
"\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"\\Tests\\": "tests/"
}
},
"authors": [
{
"name": "terremoth",
"email": "dutra.astro@gmail.com"
}
],
"minimum-stability": "stable",
"scripts": {
"fix": "vendor/bin/phpcbf",
"lint": "vendor/bin/phpcs --standard=phpcs.xml",
"analyze": "vendor/bin/psalm",
"test": "vendor/bin/phpunit tests",
"mess": "vendor/bin/phpmd src/,tests/,demos/ github cleancode,codesize,controversial,design,naming,unusedcode",
"ci": [
"@composer lint",
"@composer analyze",
"@composer mess",
"@composer test"
],
"build": [
"@composer fix",
"@composer lint",
"@composer analyze",
"@composer mess",
"@composer test"
]
}
}
12 changes: 12 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Standard"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>PHP Box Designer Coding Style</description>
<arg name="colors"/>
<rule ref="PSR12">
<type>error</type>
</rule>
<file>src</file>
<file>tests</file>
<file>demos</file>
</ruleset>
14 changes: 14 additions & 0 deletions phpmd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<ruleset name="PHPMD Complete rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="https://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Best, complete and strict configs for PHPMD</description>
<rule ref="rulesets/cleancode.xml" />
<rule ref="rulesets/codesize.xml" />
<rule ref="rulesets/controversial.xml" />
<rule ref="rulesets/design.xml" />
<rule ref="rulesets/naming.xml" />
<rule ref="rulesets/unusedcode.xml" />
</ruleset>
23 changes: 23 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
25 changes: 25 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="true"
>
<projectFiles>
<directory name="." />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<UnusedClass>
<errorLevel type="suppress">
<directory name="tests" />
</errorLevel>
</UnusedClass>
</issueHandlers>
</psalm>
Empty file added src/vendor/.gitkeep
Empty file.
Empty file added tests/vendor/.gitkeep
Empty file.

0 comments on commit 60a5e97

Please sign in to comment.