Git Product home page Git Product logo

php-starter's Introduction

PHP Example Project

An example setup for Invoke projects that use CI/CD tools

In this repo, you can see some examples for projects that will be used under our CI/CD tools.

The setup showcases the following PHP tasks:

  • Linting (via PHPStan)
  • Code Sniffing
  • Testing
  • Code Coverage

Using the code from the composer.json, these tasks will run after each composer install or composer update making it ideal for the CI/CD tools which will run those commands to prepare the project for movement to staging.

Linting

If phpstan is being painful, then feel free to use the lint.sh script. It is used in the following way:

sh ./lint.sh {path,glob,*.pattern}

Git Hooks

This project also includes a git hook for making sure the composer scripts run before a commit is made and would be difficult to undo.

To install the hooks, run:

mv hooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

This moves the script to the git directory for hooks, then changes the premissions of the file to allow execution on your local machine.

Other Script Snippets

Laravel:

"sniff": "./vendor/bin/phpcs -n --standard=PSR2 --extensions=php --colors app/ resources/views/ tests/",
"lint": "./vendor/bin/phpstan analyse -l 2 {app,resources/views,tests}/**.php",

WordPress:

Be sure to remove PHPStan when using WordPress. Since WordPress does not support PSR4, nothing is autoloaded and it is like all functions are missing...

"sniff": "./vendor/bin/phpcs -n --standard=PSR2 --extensions=php --colors wp-content/themes/{YOUR_THEME_NAME}/ tests/",
"lint": "sh ./lint.sh {wp-config.php,wp-content/themes/{YOUR_THEME_NAME}/**.php}",

php-starter's People

Contributors

james2doyle avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.