Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Jul 9, 2024
1 parent 0a49a21 commit 5c2164d
Showing 1 changed file with 5 additions and 57 deletions.
62 changes: 5 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

**Realodix Relax** is built on top of [`PHP-CS-Fixer`][php-cs-fixer] and makes it simple to to sharing identical PHP CS Fixer rules across all of your projects without copy-and-pasting configuration files.


## Installation

You can install this package by using [composer](https://getcomposer.org/):
Expand All @@ -14,6 +15,7 @@ You can install this package by using [composer](https://getcomposer.org/):
composer require --dev realodix/relax
```


## Running Relax

```sh
Expand All @@ -22,6 +24,7 @@ composer require --dev realodix/relax

For more details, see PHP-CS-Fixer [documentation](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/usage.rst).


## Configuring Relax

In your PHP CS Fixer configuration file, use the following contents:
Expand Down Expand Up @@ -75,64 +78,7 @@ By default, Relax will inspect all `.php` files in your project except those in

## Advanced Configuration
See [docs/advanced_configuration.md](docs/advanced_configuration.md) for more details.
You can find the full documentation on this page:
- [PHP-CS-Fixer: Config](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst)
- [PHP-CS-Fixer: Rules](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/rules/index.rst)
- [MLocati: PHP-CS-Fixer Configurator](https://mlocati.github.io/php-cs-fixer-configurator)


```php
<?php

use Realodix\Relax\Config;
use Realodix\Relax\Finder;

// You can add or override rule set
$localRules = [
// Add rule
'array_syntax' => true,

// Add rule or override predefined rule
'visibility_required' => true,

// Override predefined rule
'braces' => false,

// Add custom fixers
'CustomFixer/rule_1' => true,
'CustomFixer/rule_2' => true,
];

$finder = Finder::create()
->in(__DIR__)
->ignoreDotFiles(false)
->exclude(['Bar'])
->notName('*.foo.php')
->append(['.php-cs-fixer.dist.php']);

return Config::create('laravel')
->setRules($localRules)
->setFinder($finder)
->setRiskyAllowed(false)
->registerCustomFixers(new \PhpCsFixerCustomFixers\CustomFixer());
```

If you wish to completely define rules locally without using existing rule sets, you can do that:

```php
<?php

use Realodix\Relax\Config;

$localRules = [
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
];

return Config::create()
->setRules($localRules);
```

## Custom Rule Set

Expand Down Expand Up @@ -170,12 +116,14 @@ use Vendor\Package\MyRuleSet;
return Config::create(new MyRuleSet());
```


## Troubleshooting

For general help and support join our [GitHub Discussions](../../discussions).

Please report bugs to the [GitHub Issue Tracker](../../issues).


## License

This package is licensed under the [MIT License](/LICENSE).
Expand Down

0 comments on commit 5c2164d

Please sign in to comment.