bound1ess/adviser

A CLI application that checks your project for various possible improvements.

1.0.10 2015-03-17 09:01 UTC

This package is not auto-updated.

Last update: 2024-04-13 14:50:21 UTC


README

Adviser is a CLI application that checks your PHP project for various possible improvements.

Heavily inspired by phppackagechecklist.com.

Motivation

  • 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.

Navigation

Installing

Composer way

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.

Building a PHAR (Box is required)

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.

Using

analyse

This command will analyse (suggest possible improvements) the current working directory.

analyse --formatter="formattername"

Same, but the output will be formatted depending on the formatter you choose.

Available formatters:

  • plaintext (Adviser\Output\Formatters\PlainTextFormatter).

analyse-repository name [--formatter="..."]

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).

Configuring

Adviser can be configured via an adviser.yml file placed in the working directory.

Adding a Formatter

# Add a new formatter.
formatters:
    - "Your\Custom\Formatter\ClassName"
    # ...

Adding a Validator

# Add a new validator.
validators:
    - "Your\Custom\Validator\ClassName"
    # ...

Configuring a Validator

ChangelogValidator

Adviser\Validators\ChangelogValidator:
    files:
        - "CHANGELOG.md"
        # ...

CIValidator

Adviser\Validators\CIValidator:
    allowedVersions:
        - "5.6"
        - "5.5"
        - "5.4"
        - "hhvm"
        # ...

ComposerValidator

Adviser\Validators\ComposerValidator:
    autoloader: "psr-4"
    source_directory: "src"

ContributingValidator

Adviser\Validators\ContributingValidator:
    files:
        - "CONTRIBUTING.md"
        # ...

FrameworkValidator

Adviser\Validators\FrameworkValidator:
    frameworks:
        - "laravel/framework"
        # ...

LicenseValidator

Adviser\Validators\LicenseValidator:
    files:
        - "LICENSE.md"
        # ...

ReadmeValidator

Adviser\Validators\ReadmeValidator:
    files:
        - "README.md"
        # ...

TestValidator

Adviser\Validators\TestValidator:
    frameworks:
        - "phpunit/phpunit"
        # ...
    frameworkToFiles:
        phpunit/phpunit:
            - "phpunit.xml"
            - "phpunit.xml.dist"
            # ...
        # ...

Extending

  1. Write the code.
  2. Don't forget to test it!
  3. Add it to the adviser.yml configuration file (see Configuring section).
  4. Done! Share your work with others if you want to.

Creating a Validator

class YourValidator extends \Adviser\Validators\AbstractValidator
{

    /**
     * @return \Adviser\Output\MessageBag
     */
    public function handle()
    {
        // @todo
    }
}

Creating a Formatter

use Adviser\Output\MessageBag;

class YourFormatter extends \Adviser\Output\Formatters\AbstractFormatter
{

    /**
     * @param MessageBag $bag
     * @return string
     */
    public function format(MessageBag $bag)
    {
        // @todo
    }
}

Contributing

  1. Fork the project and create a local clone of it.
  2. Install the dependencies: composer update or composer install --dev.
  3. Make a fix.
  4. Run the tests: make tests.

  1. Build the coverage report:
make code-coverage
make boot-server

Now open localhost:8000 in your browser.

  1. Commit and pull!

Extra: building the documentation (ApiGen is required)

apigen --version
make build-docs boot-docs-server

Additional information

License and support information, as well as my thanks to everyone who made Adviser possible.

License

This project is licensed under the MIT license.

Support

Stuck? Found a bug? Feel free to create a new issue here on Github, or find me on Twitter.

Thanks!

To the creators of PHPUnit, Symfony, Guzzle, Mockery and Box projects.