# Getting parameter action function Slim 4

**URL:** <https://discourse.slimframework.com/t/getting-parameter-action-function-slim-4/5264>\
**Category:** Questions\
**Created:** [May 19, 2022, 5:38am UTC](https://discourse.slimframework.com/t/getting-parameter-action-function-slim-4/5264 "2022-05-19T05:38:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [May 19, 2022, 7:44am UTC](https://discourse.slimframework.com/t/getting-parameter-action-function-slim-4/5264/2 "2022-05-19T07:44:00Z")

</div>

This would work if you use the `__invoke` method instead of the `action()` method as name.

Example:

```php
<?php

namespace App\Action\Home;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

final class HomeAction
{
    public function __invoke(
        ServerRequestInterface $request,
        ResponseInterface $response,
        array $args
    ): ResponseInterface {
        $id = $args['id'];
        
        $response->getBody()->write(sprintf('The ID is: %s', $id));

        return $response;
    }
}

```

---

_[View the full topic](https://discourse.slimframework.com/t/getting-parameter-action-function-slim-4/5264)._
