Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polished docs #56

Merged
merged 3 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@
composer require contributte/console
```

```yaml
```neon
extensions:
console: Contributte\Console\DI\ConsoleExtension(%consoleMode%)
console: Contributte\Console\DI\ConsoleExtension(%consoleMode%)
```

The extension will look for all commands extending from [`Symfony\Component\Console\Command\Command`](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Command/Command.php) and automatically add them to the console application.
That's all. You don't have to worry about anything else.

## Configuration

```yaml
```neon
console:
name: Acme Project
version: '1.0'
catchExceptions: true / false
autoExit: true / false
url: https://contributte.com
lazy: false
name: Acme Project
version: '1.0'
catchExceptions: true / false
autoExit: true / false
url: https://contributte.org
lazy: false
```

In SAPI (CLI) mode there is no http request and thus no URL address. This is an inconvenience you have to solve by yourself - via the `console.url` option.

```yaml
```neon
console:
url: https://contributte.org
url: https://contributte.org
```

### Helpers
Expand All @@ -47,37 +47,37 @@ You could also define you custom `helperSet` just in case. There are 2 possible

Already defined service:

```yaml
```neon
services:
customHelperSet: App\Model\MyCustomHelperSet
customHelperSet: App\Model\MyCustomHelperSet

console:
helperSet: @customHelperSet
helperSet: @customHelperSet
```

Directly defined helperSet:

```yaml
```neon
console:
helperSet: App\Model\MyCustomHelperSet
helperSet: App\Model\MyCustomHelperSet
```

By default, helperSet contains 4 helpers defined in `Symfony\Component\Console\Application`. You can add more helpers, if need them.

```yaml
```neon
console:
helpers:
- App\Model\MyReallyGreatHelper
helpers:
- App\Model\MyReallyGreatHelper
```

### Lazy-loading

From version 3.4 `Symfony\Console` uses command lazy-loading. This extension fully supports this feature and
you can enable it in the NEON file.

```yaml
```neon
console:
lazy: true
lazy: true
```

From this point forward, all commands are instantiated only if needed. Don't forget that listing all commands will instantiate them all.
Expand All @@ -89,17 +89,17 @@ use Symfony\Component\Console\Command\Command;

class FooCommand extends Command
{
protected static $defaultName = 'app:foo';
protected static $defaultName = 'app:foo';
}
```

Or via a service tag.

```yaml
```neon
services:
commands.foo:
class: App\FooCommand
tags: [console.command: app:foo]
commands.foo:
class: App\FooCommand
tags: [console.command: app:foo]
```

## Command
Expand Down Expand Up @@ -132,9 +132,9 @@ final class FooCommand extends Command

### Register command

```yml
```neon
services:
- App\Console\FooCommand
- App\Console\FooCommand
```

Maybe you will have to flush the `temp/cache` directory.
Expand All @@ -156,9 +156,9 @@ Make sure to set it as executable. `chmod +x <root>/bin/console`.
require __DIR__ . '/../vendor/autoload.php';

exit(App\Bootstrap::boot()
->createContainer()
->getByType(Contributte\Console\Application::class)
->run());
->createContainer()
->getByType(Contributte\Console\Application::class)
->run());
```

##### Nette <= 2.4
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Website 🚀 <a href="https://contributte.org">contributte.org</a> | Contact

To install latest version of `contributte/console` use [Composer](https://getcomposer.com).

```
```bash
composer require contributte/console
```

Expand All @@ -53,5 +53,5 @@ See [how to contribute](https://contributte.org) to this package. This package i

-----

Consider to [support](https://contributte.com/partners) **contributte** development team.
Consider to [support](https://contributte.org/partners) **contributte** development team.
Also thank you for using this package.