Drupal is a registered trademark of Dries Buytaert
Release: Drupal 10.3.6 Update released for Drupal core (10.3.6)! Release: Drupal 11.0.5 Update released for Drupal core (11.0.5)! Release: Drupal 10.2.9 Update released for Drupal core (10.2.9)! Release: Drupal 10.2.10 Update released for Drupal core (10.2.10)! Release: Drupal 10.3.7 Update released for Drupal core (10.3.7)! Release: Drupal 11.0.6 Update released for Drupal core (11.0.6)! Release: Drupal 10.3.8 Update released for Drupal core (10.3.8)! Release: Drupal 11.0.7 Update released for Drupal core (11.0.7)! Module Revived: Translation Management Tool 8.x-1.19 Module tmgmt updated after 7 months of inactivity (8.x-1.19). Usage Milestone: Account field split Module account_field_split crossed 10,000 active installs.

Dex

Security covered
View on drupal.org

Console for Drupal EXtensions.

An intentionally short-lived project designed to demo the Dex proposal at #3453474: CLI entry point in Drupal Core.

Includes the necessary components to develop and register commands without needing to use a core patch.

How to use

  1. Require and enable the module.
  2. Create a new file in a module with directory/namespace: src/Command/ / Drupal\MYMODULE\Command.
  3. Add code to file:
    1. Create a class extending Symfony\Component\Console\Command\Command
    2. Add the class attribute Symfony\Component\Console\Attribute\AsCommand
  4. Clear cache
  5. Execute your new command with dex MYMODULE:command
declare(strict_types=1);

namespace Drupal\MYMODULE\Command;

use Drupal\Component\Datetime\TimeInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(name: 'MYMODULE:command', description: 'An example command.')]
final class MyCommand extends Command {

  public function __construct(
    private readonly TimeInterface $dateTime,
  ) {
    parent::__construct();
  }

  protected function execute(InputInterface $input, OutputInterface $output): int {
    $io = new SymfonyStyle($input, $output);

    $now = new \DateTimeImmutable('@' . $this->dateTime->getRequestTime());
    $io->note('The current time is ' . $now->format('r'));

    return static::SUCCESS;
  }

}

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Dec 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
1.1.0 Stable Dec 16, 2024