0

Playing around with Drupal 8 and trying to create a custom module with a custom block:

I have a module.info.yaml file:

name: Custom Module
description: Description Here
package: Custom Module
type: module
core: 8.x

dependencies:
  - block

I have a src/Plugin/CustomBlock/CustomBlock.php file:

<?php

/**
 * Provides a 'Custom' Block
 *
 * @Block(
 *   id = "custom_block",
 *   admin_label = @Translation("Custom Block"),
 * )
 */

namespace Drupal\custom_block\Plugin\Block;

use Drupal\Core\Block\BlockBase;

class CustomBlock extends BlockBase {
  /**
   * {@inheritdoc}
   */
  public function build() {
    return array(
      '#markup' => $this->t('Hello, World!'),
    );
  }
}

The module is in /modules/custom/module. I have installed contrib modules in /modules/contrib with no issue.

If I go to the Extend page, my module is not listed.

Please let me know what I am missing here?

9

Typo on the module file name:

module.info.yaml

Should be

module.info.yml
  • Yep. D8 only requires .info.yml file in order to show up on the module's page. – AjitS Apr 8 '16 at 2:47
0

Also make sure your web server has file permissions to the module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.