Skip to content

Commit 7a4d5be

Browse files
committed
documentation for laminas-cli usage
1 parent 7c60a66 commit 7a4d5be

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

README.md

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -357,49 +357,46 @@ _**Console Access**_
357357
> composer require laminas/laminas-cli --sort-packages
358358
> ```
359359
360-
and use the service in early run, like this `ErrorPreview` command:
360+
then you can see the error-preview console:
361+
362+
| Command | Preview For |
363+
|----------------------------------------------------|---------------|
364+
| vendor/bin/laminas errorheromodule:preview | Exception |
365+
| vendor/bin/laminas errorheromodule:preview error | Error |
366+
| vendor/bin/laminas errorheromodule:preview warning | PHP E_WARNING |
367+
| vendor/bin/laminas errorheromodule:preview fatal | PHP Fatal |
368+
369+
You will get the following page if display_errors config is 0:
370+
371+
![error preview in console](https://user-images.githubusercontent.com/459648/206882602-5f2e5ab0-86d6-4694-9a3c-c7b8896596fa.png))
372+
373+
You can use the error handling in your console application, by extends `BaseLoggingCommand`, like below:
361374
362375
```php
363-
namespace App\Command;
376+
namespace Application\Command;
364377
365378
use ErrorHeroModule\Command\BaseLoggingCommand;
366-
use Symfony\Component\Console\Command\Command;
379+
use Exception;
367380
use Symfony\Component\Console\Input\InputArgument;
368381
use Symfony\Component\Console\Input\InputInterface;
369382
use Symfony\Component\Console\Output\OutputInterface;
370383
371-
use function sprintf;
372-
373-
final class ErrorPreview extends BaseLoggingCommand
384+
final class HelloWorld extends BaseLoggingCommand
374385
{
375386
protected function configure()
376387
{
377388
$this
378389
->addArgument('message', InputArgument::REQUIRED, 'Greeting Message');
379390
}
380391
381-
protected function execute(InputInterface $input, OutputInterface $output)
392+
protected function execute(InputInterface $input, OutputInterface $output): int
382393
{
383-
$message = $input->getArgument('message');
384-
$output->writeln(sprintf('<info>Hello to world: %s<info>! ', $message));
394+
throw new Exception('some exception logged to DB');
385395
}
386396
}
387397
```
388398
389-
and register to your services (the `ErrorPreview` already exists by default), then you can preview:
390-
391-
| Command | Preview For |
392-
|----------------------------------------------|---------------|
393-
| vendor/bin/laminas app:error-preview | Exception |
394-
| vendor/bin/laminas app:error-preview error | Error |
395-
| vendor/bin/laminas app:error-preview warning | PHP E_WARNING |
396-
397-
You will get the following page if display_errors config is 0:
398-
399-
// TODO: update screenshot
400-
![error preview in console](https://cloud.githubusercontent.com/assets/459648/21669141/8e7690f0-d33b-11e6-99c7-eed4f1ab7edb.png)
401-
402-
> For production env, you can disable error-preview sample page with set `['error-hero-module']['enable-error-preview-page']` to false.
399+
and register to your services like in the [documentation](https://docs.laminas.dev/laminas-cli/intro/).
403400
404401
Contributing
405402
------------

0 commit comments

Comments
 (0)