2

I'm installing drush v9 on the server as well as I try to port my command. I did several things but now get the error:

drush status

In BespokeDocBlockParser.php line 65:

  Could not determine command name from tag @command

I really have no idea where to look. I googled for the php file but could not even find it :-(

Any suggestion is appreciated. ...

I removed the drush.services.yml and rebuild the cache. Drush status is now giving normal feedback so probably it is sometiming in the drush command.

My drupal.services.yml

services:
  tb.commands:
    class: \Drupal\tb\Commands\TbCommands
    tags:
      - { name: drush.command }

My generated php template

<?php

namespace Drupal\tb\Commands;

use Drush\Commands\DrushCommands;

/**
 * A Drush commandfile.
 *
 * In addition to this file, you need a drush.services.yml
 * in root of your module, and a composer.json file that provides the name
 * of the services file to use.
 *
 * See these files for an example of injecting Drupal services:
 *   - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php
 *   - http://cgit.drupalcode.org/devel/tree/drush.services.yml
 */
class TbCommands extends DrushCommands {

  /**
   * Start data collecting for the traderbot
   *
   * @param $para
   *   parameters in case i need this
   * @validate-module-enabled tb
   *
   * @command 
   * @aliases tb,traderbot
     */

    public function traderbot($para) {
      // See bottom of https://weitzman.github.io/blog/port-to-drush9 for details on what to change when porting a
      // legacy command.

    tb_log(3,'Start runnning traderbot from drush');



    tb_log(3,'End runnning traderbot from drush');

    }

}

The composer.json

{
    "name": "org/tb",
    "description": "This extension provides new commands for Drush.",
    "type": "drupal-drush",
    "authors": [
        {
            "name": "Author name",
            "email": "author@example.com"
        }
    ],
    "require": {
        "php": ">=5.6.0"
    },
    "extra": {
        "drush": {
            "services": {
                "drush.services.yml": "^9"
            }
        }
    }
}

function tb_log is part of the custom tb drupal module.

What is wrong?

1

The comment on the traderbot method is incorrect:

   * @command 
   * @aliases tb,traderbot

There is no value after @command. I believe you want:

   * @command traderbot
   * @aliases tb

See: Porting Commands to Drush 9

Clear the cache after the change and try again.

  • 1
    Yes this is working. Very odd that drush 9 uses things in comment to have this working... – Justme May 22 '18 at 13:24
  • Drupal 8 etc makes a lot of usage of Annotations for definition and discovery. It’s new for 8.x devs but not necessarily a new paradigm. – Kevin May 22 '18 at 13:26
  • Will dive into it. – Justme May 22 '18 at 13:33

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.