Programmatically create a custom block in Drupal 8
Submitted by admin on Tue, 12/12/2017 - 17:19
- It seems that we cannot create a custom block in existing modules on drupal 8. So you must create a new custom module first.
- create a .info.yml file like so: /modules/custom_blocks/custom_blocks.info.yml
name: All My Custom Blocks type: module description: Defines a custom block. core: 8.x package: Custom dependencies: - block
- create a .info.yml file like so: /modules/custom_blocks/custom_blocks.info.yml
- Create the following file /modules/custom_blocks/src/Plugin/Block/MyFirstBlock.php