https://github.com/dbfx/github-phplint
Automatically run 'php -l' on all PHP files in a repository with Github Actions
https://github.com/dbfx/github-phplint
Last synced: 5 months ago
JSON representation
Automatically run 'php -l' on all PHP files in a repository with Github Actions
- Host: GitHub
- URL: https://github.com/dbfx/github-phplint
- Owner: dbfx
- License: mit
- Created: 2020-01-27T12:15:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-15T02:04:28.000Z (over 1 year ago)
- Last Synced: 2024-11-15T03:17:12.530Z (over 1 year ago)
- Language: Dockerfile
- Homepage:
- Size: 24.4 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Lint GitHub Action
This Github Action runs `php -l` on all PHP files found in the current project. It allows you to easily and quickly check for
any syntax / parse errors in your PHP files on pull requests or pushes. This is especially useful for code that is
meant to run on multiple PHP versions.
---
## Getting Started
Using this action to check for syntax / parse errors for PHP versions 7.4, 8.0, and 8.4 can be done with the following template:
```
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: PHP Lint 7.4
uses: dbfx/github-phplint/7.4@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
- name: PHP Lint 8.0
uses: dbfx/github-phplint/8.0@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
- name: PHP Lint 8.4
uses: dbfx/github-phplint/8.4@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
```
---
## Brand New Setup
If you have never used github actions, then create a file called phplint.yml in your Git repository in the directory
.github/workflows. Inside of .github/workflows/phplint.yml put the following text:
```
name: PHP Linting
on: push
jobs:
phplint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: PHP Lint 7.2
uses: dbfx/github-phplint/7.2@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
- name: PHP Lint 7.3
uses: dbfx/github-phplint/7.3@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
- name: PHP Lint 7.4
uses: dbfx/github-phplint/7.4@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
- name: PHP Lint 8.0
uses: dbfx/github-phplint/8.0@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
- name: PHP Lint 8.1
uses: dbfx/github-phplint/8.1@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
- name: PHP Lint 8.2
uses: dbfx/github-phplint/8.2@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
- name: PHP Lint 8.3
uses: dbfx/github-phplint/8.3@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
- name: PHP Lint 8.4
uses: dbfx/github-phplint/8.4@master
with:
folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\""
```
If you want to run the lint on Pull Requests instead of pushes change the ```on: push``` to ```on: pull```.
In the above example, your workflow will run the PHP syntax check with PHP 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, and 8.4. You may remove any of these that do not apply.
---
## Supported versions
Right now there is support for the following PHP versions:
- 5.5
- 5.6
- 7.2
- 7.3
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
- 8.4
If you would like to add more submit a PR or an issue.
---
## Ignoring paths
You can see in the above examples it ignores certain paths. You may add as many as you need by copying the example.
The action ignores the folder `vendor` at root of project by default.
---
## Original work
This is based on PrestaShop's original work https://github.com/PrestaShopCorp/github-action-php-lint.