Answers.Body: <p>If you want to explicitly grab them from PHP, this should also work:</p>
  
  <pre><code>$result = Craft::$app-&gt;getRequest()-&gt;resolve();
  </code></pre>
  
  <p>From there, you could grab <code>$result[1]</code>, which should be an array:</p>
  
  <pre><code>array(
      'variables' =&gt; array(
          'post_id' =&gt; 3,
      ,
      'template' =&gt; 'post-entry',
      'p' =&gt; 'post/3',
  )
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T08:33:14.460Z
Answers.Text: For the `routes.php` configuration: `'post/<post_id:\d+>' => [ 'template' => 'post-entry']`, the value of $params is `array( "template"=> "post-entry)"` No clue of post_id but it's available in the template when I do `{{ post_id }}` Did I misunderstand something?
Answers.UserDisplayName: Rosana Ruiz
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T09:05:52.083Z
Answers.Text: It's also not available in the template if I do `{{ dump(craft.app.urlManager.routeParams()) }}`, this displays: `array(1) { ["template"]=> string(9) "post-entry" } `. But `{{ post_id }}` => `3` So **a)** I am missing an extra configuration or **b)** it's not there...
Answers.UserDisplayName: Rosana Ruiz
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T23:46:59.760Z
Answers.Text: Updated answer... should be more reliable and take into account your route.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-10T18:23:16.323Z
Answers.LastActivityDate: 2018-05-11T23:46:26.020Z
Answers.LastEditDate: 2018-05-11T23:46:26.020Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>It is passed as a parameter to your function</p>
  
  <pre><code>public function actionView($post_id){
      Craft::dd($post_id);
  }
  </code></pre>
  
  <p>Note: your parameter <strong>must</strong> have the <strong>same</strong> name like defined in your route. You can't access it with <code>public function actionView($postId)</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-10T18:13:33.260Z
Answers.LastActivityDate: 2018-05-10T18:13:33.260Z
Answers.UserDisplayName: Robin Schambach
Body: <p>Yii's <a href="https://www.yiiframework.com/doc/guide/2.0/en/runtime-routing#named-parameters" rel="nofollow noreferrer">named parameters</a> are available in the template. For example, for the following route configuration:</p>
  
  <pre><code>'post/&lt;post_id:\d+&gt;' =&gt; ['template' =&gt; 'post-entry'],
  </code></pre>
  
  <p>The value of <code>post_id</code> in my template for the request <code>post/3</code> will be <code>3</code>.</p>
  
  <p>But <strong>how can I access it from PHP</strong>, for example from the <code>Craft::app -&gt; getRequest()</code> ? </p>
  
  <p><strong>Note:</strong> I don't mean queryString parameters. QueryString parameters can be accessed using <code>getParam('paramName')</code>.</p>
  
Tags: <craft3><params>
Title: Get a named parameter value from request
ThreadText: # Get a named parameter value from request
  
  (Asked by: username_0 on 2018-05-10)
  
  Yii's [named parameters](https://www.yiiframework.com/doc/guide/2.0/en/runtime-routing#named-parameters) are available in the template. For example, for the following route configuration:
  
  ```
  'post/<post_id:\d+>' => ['template' => 'post-entry'],
  
  ```
  
  The value of `post_id` in my template for the request `post/3` will be `3`.
  
  But **how can I access it from PHP**, for example from the `Craft::app -> getRequest()` ?
  
  **Note:** I don't mean queryString parameters. QueryString parameters can be accessed using `getParam('paramName')`.
  
  **Tags:** craft3, params
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-05-10. Score: 3 | Accepted answer
  
  If you want to explicitly grab them from PHP, this should also work:
  
  ```
  $result = Craft::$app->getRequest()->resolve();
  
  ```
  
  From there, you could grab `$result[1]`, which should be an array:
  
  ```
  array(
      'variables' => array(
          'post_id' => 3,
      ,
      'template' => 'post-entry',
      'p' => 'post/3',
  )
  
  ```
  
  > **Comments:**
  > **username_0**: For the `routes.php` configuration: `'post/<post_id:\d+>' => [ 'template' => 'post-entry']`, the value of $params is `array( "template"=> "post-entry)"` No clue of post_id but it's available in the template when I do `{{ post_id }}` Did I misunderstand something?  
  > **username_0**: It's also not available in the template if I do `{{ dump(craft.app.urlManager.routeParams()) }}`, this displays: `array(1) { ["template"]=> string(9) "post-entry" } `. But `{{ post_id }}` => `3` So **a)** I am missing an extra configuration or **b)** it's not there...  
  > **username_1**: Updated answer... should be more reliable and take into account your route.  
  
  ---
  
  ### Answer by username_2 on 2018-05-10. Score: 4
  
  It is passed as a parameter to your function
  
  ```
  public function actionView($post_id){
      Craft::dd($post_id);
  }
  
  ```
  
  Note: your parameter **must** have the **same** name like defined in your route. You can't access it with `public function actionView($postId)`
  
  
  ---
  
  