# Using custom helper in command

**URL:** https://discourse.cakephp.org/t/using-custom-helper-in-command/10819
**Category:** Need Help
**Created:** [December 14, 2022, 1:19am UTC](https://discourse.cakephp.org/t/using-custom-helper-in-command/10819 "2022-12-14T01:19:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![snowcity1611](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@snowcity1611](https://discourse.cakephp.org/u/snowcity1611)
#### Post date: [December 14, 2022, 1:19am UTC](https://discourse.cakephp.org/t/using-custom-helper-in-command/10819/1 "2022-12-14T01:19:14Z")

</div>

I want to use a custom helper in a custom command. From :

[https://book.cakephp.org/4/en/console-commands/input-output.html#command-helpers](https://book.cakephp.org/4/en/console-commands/input-output.html#command-helpers)

it appears I need to :

1. create my helper in src/command/helper instead of view//helper
2. Call it with :

$this-\>helper(‘MyHelper’)-\>someFunction(“test”);

However when I do this I get:

Call to undefined method App\Command\myCommand::helper()

Did I misunderstand something? It seems that helper is not defined?

Thanks!

---

<div class="post-metadata">

### Author: ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)
#### Post date: [December 14, 2022, 5:20am UTC](https://discourse.cakephp.org/t/using-custom-helper-in-command/10819/2 "2022-12-14T05:20:38Z")

</div>

I haven’t used this functionality, but I wonder if there’s an issue in the docs. The large majority of examples on the page you linked use `$io->helper()`, so it would seem to be a function of the ConsoleIo class, not the command class. `$this->helper()` maybe a typo.

---

<div class="post-metadata">

### Author: ![Kaiser85](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kaiser85/32/2714_2.png) [@Kaiser85](https://discourse.cakephp.org/u/Kaiser85)
#### Post date: [May 9, 2023, 5:16pm UTC](https://discourse.cakephp.org/t/using-custom-helper-in-command/10819/4 "2023-05-09T17:16:14Z")

</div>

As Zuluru said, apparently the right way to call a command helper is this way:

```auto
$io->helper('Heading')->output(['It works!']);

```

![imagen](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/4/42f9ab2047df5af30426c02b2dc7cdc01c7f755d.png)

Were `test` is the name of the command and `Heading` the name of the command helper

I have tested this and it works this way
