VOOZH about

URL: https://deepwiki.com/hypervel/devtool/12-development-tools

⇱ Development Tools | hypervel/devtool | DeepWiki


Loading...
Menu

Development Tools

Purpose and Scope

This document covers the non-generator utility commands provided by the Hypervel Devtool package for development workflow enhancement. Unlike the code generation commands (documented in sections 4 through 11), these tools interact with the running application to provide debugging assistance and automated development server management.

The two utility commands are:

  • watch - Hot-reload file watcher that automatically restarts the development server when files change
  • event:list - Event system inspector that displays registered events and their listeners

For information about code generation commands, see Code Generation System.

Command Overview

The development utility commands serve fundamentally different purposes than generator commands. While generators create new files from templates, utility commands introspect or manage the runtime application state.

CommandClassPurposeDependencies
watchWatchCommandMonitor file changes and restart serverhyperf/watcher package
event:listEventListCommandDisplay registered events and listenersEventDispatcherContract implementation

Both commands extend Hyperf\Command\Command directly rather than GeneratorCommand, indicating they do not follow the stub-based file generation pattern.

Sources: src/Commands/WatchCommand.php17-29 src/Commands/EventListCommand.php18-23

Architectural Distinction from Generators

Utility Command Pattern


Utility Command Characteristics:

Generator commands inherit from GeneratorCommand and follow a template-based file creation pattern. Utility commands inherit directly from Hyperf\Command\Command and implement runtime interaction patterns:

  1. No File Generation - They do not create or modify files in the application codebase
  2. Runtime Interaction - They query or manage the running application state
  3. External Dependencies - They may require specific packages or contracts to be available
  4. Continuous Execution - Commands like watch run continuously rather than executing once

Sources: src/Commands/WatchCommand.php17-18 src/Commands/EventListCommand.php18

Command Registration and Discovery

Integration with ConfigProvider


Both utility commands are registered through the same ConfigProvider mechanism as generator commands. The ConfigProvider1-80 performs a check for GeneratorCommand existence before registering any commands, ensuring graceful degradation if Hyperf's devtool is not installed.

Sources: Referenced from system context; specific implementation in src/ConfigProvider.php

Utility Command Implementations

WatchCommand Architecture

The WatchCommand provides hot-reload functionality by monitoring the file system and restarting the server when changes are detected:


The command src/Commands/WatchCommand.php31-65 implements a configuration cascade:

  1. Reads config('watcher') from application configuration
  2. Falls back to default configuration from vendor/hyperf/watcher/publish/watcher.php
  3. Merges custom configuration from .watcher.php file if present
  4. Applies CLI options (--dir, --file, --no-restart)

Key Configuration Options:

OptionFlagTypeDefaultDescription
config-Cstring.watcher.phpCustom configuration file path
file-Farray[]Additional files to watch
dir-Darray[]Additional directories to watch
no-restart-NflagfalseMonitor only, don't restart server

The command sets a default command value of 'artisan serve' if not specified in configuration src/Commands/WatchCommand.php48-50

Sources: src/Commands/WatchCommand.php17-66

EventListCommand Architecture

The EventListCommand introspects the event system to display registered events and their listeners:


The command src/Commands/EventListCommand.php25-33 retrieves the EventDispatcherInterface from the container and checks if it implements EventDispatcherContract src/Commands/EventListCommand.php45-47 This contract provides the getRawListeners() method necessary for introspection.

Listener Formatting Logic:

The command src/Commands/EventListCommand.php66-86 formats different listener types:

  1. Array Callable - [Class, 'method'] → formatted as Class::method
  2. String Callable - Class name or function name → displayed as-is
  3. Closure - Anonymous function → displayed as 'Closure'
  4. Unknown - Unrecognized format → displayed as 'Unknown listener'

Filtering Options:

OptionShortTypePurpose
--event-estringFilter events by name (substring match)
--listener-lstringFilter listeners by name (substring match)

The filtering uses str_contains() for substring matching src/Commands/EventListCommand.php54 and src/Commands/EventListCommand.php63 allowing partial name searches.

Sources: src/Commands/EventListCommand.php18-108

Development Workflow Integration

Hot-Reload Development Cycle


The watch command enables a fast feedback loop during development by eliminating manual server restarts. The command continues running until terminated by the developer.

Sources: src/Commands/WatchCommand.php31-65

Event System Debugging Workflow


The event:list command helps developers verify event-listener bindings, discover registered events, and debug event system configuration issues.

Sources: src/Commands/EventListCommand.php25-108

Detailed Command Documentation

For comprehensive documentation of each utility command, including all options, configuration details, and usage examples, see:

Sources: Referenced from table of contents structure