Programmatically creating a custom block

Provided our module is called customblock add the file CustomblockBlock.php to src/Plugin/Block. Inside it put something along the lines of:

<?php
/**
 * @file
 * Contains \Drupal\customblock\Plugin\Block\CustomblockBlock.
 */
namespace Drupal\customblock\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormInterface;

/**
 * Provides a 'customblock' block.
 *
 * @Block(
 *   id = "customblock_block",
 *   admin_label = @Translation("Custom block"),
 *   category = @Translation("Custom blocks")
 * )
 */
class CustomblockBlock extends BlockBase {
  /**
   * {@inheritdoc}
   */
  public function build() {
	  
	  return array(
		'#markup' => $this->t('This is the content of our block.'),
		);
   }
}