2017 © Pedro Peláez
 

library prettyhp

PrettyHP is an opinionated PHP code formatter

image

dusterio/prettyhp

PrettyHP is an opinionated PHP code formatter

  • Wednesday, January 24, 2018
  • by dusterio
  • Repository
  • 2 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

prettyhp

Logo, (*1)

Build Status Code Climate Latest Stable Version Total Downloads License, (*2)

PrettyHP is an opinionated PHP code formatter, (*3)

It removes all original styling and ensures that all outputted code conforms to a consistent style., (*4)

PrettyHP will try to comply with PSR as much as possible., (*5)

Inspired by JavaScript's prettier, (*6)

But why?

Your IDE or editor may already have some basic formatting built-in, but:, (*7)

  • At least PhpStorm cannot re-format code automatically before committing to VCS;
  • Different team members may have different editors, views and standards;
  • At least PhpStorm doesn't really enforce styling, it just does some basic indenting.

Why not use existing PHP code formatters?, (*8)

phpfmt

phpfmt is officially closed, the repo is deleted by the authors., (*9)

php-cs-fixer

I'm a very experienced developer and Linux user, yet I couldn't get it up and running in 10+ minutes. Something is just wrong about it. Since the tool's verbose mode is not implemented, I couldn't debug it any further., (*10)

Installation

$ composer require --dev dusterio/prettyhp

We recommend to add a pre-commit Git hook so that any modified PHP files are prettified right before the commit:, (*11)

$ cat .git/hooks/pre-commit

git diff --staged --diff-filter=dx --name-only HEAD | grep ".*\.php$" | xargs -I % sh -c 'vendor/bin/prettyhp format %; git add %'

Manual usage

PrettyHP is meant for PSR 4 compliant files – one file should contain one PHP class., (*12)

$ vendor/bin/prettyhp [filename]

The Versions

24/01 2018

dev-master

9999999-dev https://github.com/dusterio/prettyhp

PrettyHP is an opinionated PHP code formatter

  Sources   Download

MIT

The Requires

 

The Development Requires

php formatter linter pretty consistency styling prettifier