Adviser is a CLI application that checks your PHP project for various possible improvements.
Heavily inspired by phppackagechecklist.com.
- Do I have some sort of a license file?
- Is my composer.json valid?
- Is my code PSR-2 compatible?
- Are the repository tags and settings OK?
I often ask myself such questions. And I got tired of checking it all manually every time. Here comes Adviser to make things a lot easier.
Just run in your terminal (you should be in your project's root directory):
composer require --dev bound1ess/adviser
Or, if you don't have Composer installed globally:
curl -sS https://getcomposer.org/installer | php
./composer.phar require --dev bound1ess/adviser
Now you should be able to run vendor/bin/adviser
and see Adviser's CLI.
This is not very difficult to do either, just run:
box --version
git clone https://github.com/bound1ess/adviser.git
cd adviser
composer update # Assuming that it's installed globally.
make build-phar
Now you can use builds/adviser.phar
, or (only if you want to!) you can also do this:
sudo mv builds/adviser.phar /usr/local/bin/adviser
Now you can use adviser
(everywhere!) instead of builds/adviser.phar
.
This command will analyse (suggest possible improvements) the current working directory.
Same, but the output will be formatted depending on the formatter you choose.
Available formatters:
plaintext
(Adviser\Output\Formatters\PlainTextFormatter
).
The name
argument here is a Github repository name (e.g. bound1ess/adviser
).
This command will make a local clone of it, run the analyse
command, then remove it (directory).
Adviser can be configured via an adviser.yml
file placed in the working directory.
# Add a new formatter.
formatters:
- "Your\Custom\Formatter\ClassName"
# ...
# Add a new validator.
validators:
- "Your\Custom\Validator\ClassName"
# ...
Adviser\Validators\ChangelogValidator:
files:
- "CHANGELOG.md"
# ...
Adviser\Validators\CIValidator:
allowedVersions:
- "5.6"
- "5.5"
- "5.4"
- "hhvm"
# ...
Adviser\Validators\ComposerValidator:
autoloader: "psr-4"
source_directory: "src"
Adviser\Validators\ContributingValidator:
files:
- "CONTRIBUTING.md"
# ...
Adviser\Validators\FrameworkValidator:
frameworks:
- "laravel/framework"
# ...
Adviser\Validators\LicenseValidator:
files:
- "LICENSE.md"
# ...
Adviser\Validators\ReadmeValidator:
files:
- "README.md"
# ...
Adviser\Validators\TestValidator:
frameworks:
- "phpunit/phpunit"
# ...
frameworkToFiles:
phpunit/phpunit:
- "phpunit.xml"
- "phpunit.xml.dist"
# ...
# ...
- Write the code.
- Don't forget to test it!
- Add it to the
adviser.yml
configuration file (see Configuring section). - Done! Share your work with others if you want to.
class YourValidator extends \Adviser\Validators\AbstractValidator
{
/**
* @return \Adviser\Output\MessageBag
*/
public function handle()
{
// @todo
}
}
use Adviser\Output\MessageBag;
class YourFormatter extends \Adviser\Output\Formatters\AbstractFormatter
{
/**
* @param MessageBag $bag
* @return string
*/
public function format(MessageBag $bag)
{
// @todo
}
}
- Fork the project and create a local clone of it.
- Install the dependencies:
composer update
orcomposer install --dev
. - Make a fix.
- Run the tests:
make tests
.
- Build the coverage report:
make code-coverage
make boot-server
Now open localhost:8000
in your browser.
- Commit and pull!
apigen --version
make build-docs boot-docs-server
License and support information, as well as my thanks to everyone who made Adviser possible.
This project is licensed under the MIT license.
Stuck? Found a bug? Feel free to create a new issue here on Github, or find me on Twitter.
To the creators of PHPUnit, Symfony, Guzzle, Mockery and Box projects.