Unable to show form using controller (module) I want to make custom page in drupal with form, I checked few examples showing page in drupal via module and example of form via module, i tried to merge them but no success.
I made a custom page using drupal module with template (twig) file. 

Below is my controller code

namespace Drupal\booktestdrive\Controller;
use Drupal\Core\Controller\ControllerBase;

class BiveController extends ControllerBase {
  public function show() {
    $form_class = '\Drupal\booktestdrive\Form\TestForm';
    return [
        '#theme' =&gt; 'bive_page_theme',
        '#form' =&gt; \Drupal::formBuilder()-&gt;getForm($form_class),
    ];
  }
}


Template file code

bive_page_theme.html.twig

&lt;section&gt; hii
{{ form }}

&lt;/section&gt;


i also created form at src/form/BiveForm.php

namespace Drupal\bive\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class BiveForm extends FormBase {
  public function getFormId() {
    return 'booktestdrive_form';
  }
  public function buildForm(array $form, FormStateInterface $form_state) {

    $form['first_name'] = array(
      '#type' =&gt; 'textfield',
      '#attributes' =&gt;array('placeholder' =&gt; t('First Name*')),
      '#required' =&gt; TRUE,
    );

    $form['last_name'] = array(
      '#type' =&gt; 'textfield',
      '#attributes' =&gt;array('placeholder' =&gt; t('Last Name')),
      '#required' =&gt; FALSE,
    );

    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; $this-&gt;t('Save'),
      '#button_type' =&gt; 'primary',
    );
    return $form;
  }

    public function validateForm(array &amp;$form, FormStateInterface $form_state) {

      if (strlen($form_state-&gt;getValue('candidate_number')) &lt; 10) {
        $form_state-&gt;setErrorByName('candidate_number', $this-&gt;t('Mobile number is too short.'));
      }

    }


  public function submitForm(array &amp;$form, FormStateInterface $form_state) {

   // drupal_set_message($this-&gt;t('@can_name ,Your application is being submitted!', array('@can_name' =&gt; $form_state-&gt;getValue('candidate_name'))));

    foreach ($form_state-&gt;getValues() as $key =&gt; $value) {
      drupal_set_message($key . ': ' . $value);
    }

   }
}


Routing.yml

bdrive.book:
  path: '/brive'
  defaults:
    _controller: 'Drupal\brive\Controller\BriveController::book'
    _title: 'Test'
  requirements:
    _permission: 'access content'

brive.form:
 path: '/brive-form'
 defaults:
   _title: 'Application form'
   _form: '\Drupal\booktestdrive\Form\BriveForm'
 requirements:
   _permission: 'access content'
You need define new function theme bive_page_theme before call it. You can see docs and example. In your case, you can write more code in file .module

/**
 * Implements hook_theme().
 */
function Your_Module_theme($existing, $type, $theme, $path) {
    return [
        'bive_page_theme' =&gt; [
            'variables' =&gt; [
              'form' =&gt; NULL,
            ],
            'path' =&gt; $path . '/templates',
        ]
    ];
}


and create file bive_page_theme.html.twig in folder templates of module. Clear cache and go to page.