PHPackages                             finetuned/modx-cli - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. finetuned/modx-cli

ActiveLibrary[CLI &amp; Console](/categories/cli)

finetuned/modx-cli
==================

MODX 3 CLI

0.11.0-beta(1mo ago)97MITPHPPHP &gt;=8.1

Since Mar 27Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/Finetuned/modx-cli)[ Packagist](https://packagist.org/packages/finetuned/modx-cli)[ GitHub Sponsors](https://github.com/finetunedltd)[ Fund](https://opencollective.com/modx-cli)[ RSS](/packages/finetuned-modx-cli/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (25)Versions (19)Used By (0)

MODX CLI
========

[](#modx-cli)

A command-line interface for MODX 3, built with Symfony Console.

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- MODX 3.0.0 or higher

Installation
------------

[](#installation)

### Via Composer

[](#via-composer)

```
composer global require finetuned/modx-cli
```

### Manual Installation

[](#manual-installation)

1. Clone the repository:

```
git clone https://github.com/finetuned/modx-cli.git
cd modx-cli
```

2. Install dependencies:

```
composer install
```

3. Make the CLI executable:

```
chmod +x bin/modx
```

4. Create a symbolic link to make the CLI available globally:

```
sudo ln -s $(pwd)/bin/modx /usr/local/bin/modx
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
modx [command] [options]
```

### Available Commands

[](#available-commands)

When a MODX instance is configured and set as default, many commands become available, including:

- `version` - Display the CLI version
- `self-update` - Update MODX CLI when installed as a Phar
- `system:info` - Get general system information
- `system:clearcache` - Clear the MODX cache
- `resource:list` - Get a list of resources
- `resource:create` - Create a MODX resource
- `resource:update` - Update a MODX resource (supports partial updates)
- `chunk:list` - Get a list of chunks
- `chunk:create` - Create a MODX chunk
- `chunk:update` - Update a MODX chunk (supports partial updates)
- `template:list` - Get a list of templates
- `template:create` - Create a MODX template
- `template:update` - Update a MODX template (supports partial updates)
- `snippet:list` - Get a list of snippets
- `snippet:create` - Create a MODX snippet
- `snippet:update` - Update a MODX snippet (supports partial updates)
- `tv:list` - Get a list of template variables
- `tv:create` - Create a MODX template variable
- `tv:update` - Update a MODX template variable (supports partial updates)
- `user:list` - Get a list of users
- `user:get` - Get a user by ID or username
- `user:create` - Create a user
- `user:update` - Update a user
- `user:remove` - Remove a user
- `user:activate` - Activate a user
- `user:deactivate` - Deactivate a user
- `user:block` - Block a user
- `user:unblock` - Unblock a user
- `user:resetpassword` - Reset a user password
- `package:list` - Get a list of packages (supports pagination)
- `crawl` - Crawl resources to prime their caches
- And many more

To see all available commands, run:

```
modx list
```

#### Command Features

[](#command-features)

**Update Commands**: All update commands now support partial updates - you only need to specify the ID and the fields you want to change. The CLI automatically fetches existing data to populate required fields.

**List Commands**: All list commands support pagination with `--limit` and `--start` options for navigating large datasets.

**JSON Output**: All commands support `--json` flag for machine-readable output.

**Enhanced Logging**: Built-in PSR-3 compliant logging system with file logging, automatic rotation, and verbosity controls.

### Logging

[](#logging)

The CLI includes a comprehensive logging system for better debugging and operational visibility:

```
# Control console output verbosity
modx command -v          # verbose
modx command -vv         # very verbose
modx command -vvv        # debug
modx command --quiet     # no output

# Write logs to a file
modx command --log-file=/var/log/modx-cli.log

# Set log level (filters which messages are logged)
modx command --log-level=debug
```

All commands extending `BaseCmd` have automatic access to logging:

```
$this->logInfo('Processing started');
$this->logDebug('Item {id} processed', ['id' => 123]);
$this->logError('Operation failed: {error}', ['error' => $e->getMessage()]);
```

For complete documentation, see [Enhanced Logging System](docs/enhanced-logging-system.md).

### Plugin Architecture

[](#plugin-architecture)

MODX CLI features a powerful plugin system for extending functionality without modifying core code:

```
// Create a plugin by extending AbstractPlugin
class MyPlugin extends AbstractPlugin
{
    public function getName(): string
    {
        return 'my-plugin';
    }

    public function getCommands(): array
    {
        return [MyCommand::class];
    }

    public function getHooks(): array
    {
        return [
            'command.before' => [$this, 'onCommandBefore']
        ];
    }
}
```

**Features:**

- Automatic plugin discovery and loading
- Hook system for event-driven extensions
- Command registration
- Configuration management
- Enable/disable functionality

For complete documentation, see [Plugin Architecture](docs/plugin-architecture.md).

### Command Output Streaming

[](#command-output-streaming)

Enhanced output capabilities for long-running commands:

```
class MyCommand extends BaseCmd
{
    use StreamingOutputTrait;

    protected function process()
    {
        // Progress bars
        $this->startProgress(100, 'Processing...');
        $this->advanceProgress(10);
        $this->finishProgress();

        // Real-time streaming
        $this->stream('Processing item...');

        // Section-based output
        $section = $this->createSection();
        $section->write('Status: Running');
        $section->overwrite('Status: Complete');

        return 0;
    }
}
```

**Features:**

- Real-time streaming output
- Progress bars with custom formats
- Buffered and unbuffered modes
- Section-based output
- Event callbacks and statistics

For complete documentation, see [Command Output Streaming](docs/command-output-streaming.md).

### Examples

[](#examples)

Display the CLI version:

```
modx version
```

Get system information:

```
modx system:info
```

Clear the MODX cache:

```
modx system:clearcache
```

Get a list of resources:

```
modx resource:list
```

Get a list of resources with filters and pagination:

```
modx resource:list --parent=1 --context=web --published=1 --limit=20 --start=0
```

#### Update Command Examples

[](#update-command-examples)

Update only the title of a resource (partial update):

```
modx resource:update 123 --pagetitle="New Title"
```

Update multiple fields of a chunk:

```
modx chunk:update 5 --description="Updated description" --snippet="New content"
```

Update a template variable with new default value:

```
modx tv:update 10 --default_text="New default value" --description="Updated TV"
```

#### Create Command Examples

[](#create-command-examples)

Create a new resource with specific settings:

```
modx resource:create "My New Page" --parent=1 --template=2 --published=1
```

Create a new chunk:

```
modx chunk:create "MyChunk" --description="A new chunk" --snippet="Chunk content"
```

#### List Command Examples with Pagination

[](#list-command-examples-with-pagination)

Get the first 10 packages:

```
modx package:list --limit=10 --start=0
```

Get the next 10 packages:

```
modx package:list --limit=10 --start=10
```

#### JSON Output Examples

[](#json-output-examples)

Get resource data in JSON format:

```
modx resource:get 123 --json
```

Get a list of templates in JSON format:

```
modx template:list --json
```

### Working with Multiple MODX Instances

[](#working-with-multiple-modx-instances)

Most commands in the MODX CLI require a MODX instance to be available. To see all available commands, you need to configure at least one MODX instance and set it as the default.

To add a MODX instance:

```
modx config:add mysite --base_path=/path/to/modx/
```

To set a MODX instance as the default:

```
modx config:set-default mysite
```

You can also specify a MODX instance to run a command on:

```
modx --site=mysite system:info
```

### SSH and Aliases

[](#ssh-and-aliases)

MODX CLI supports running commands on remote servers via SSH and using aliases to simplify working with multiple MODX installations.

#### SSH Mode

[](#ssh-mode)

Run commands on a remote server:

```
modx --ssh=user@example.com:/path/to/modx system:info
```

#### Aliases

[](#aliases)

Define aliases in `~/.config/modx-cli/config.yml` or `modx-cli.yml` in your project directory:

```
@prod:
  ssh: user@production-server.com:/path/to/modx
@staging:
  ssh: user@staging-server.com:/path/to/modx
@local:
  base_path: /var/www/modx
```

Use aliases to run commands:

```
modx @prod system:info
modx @local resource:list
```

Define alias groups to run commands on multiple servers:

```
@all:
  - @prod
  - @staging
```

```
modx @all system:clear-cache
```

For more information, see [SSH and Aliases Documentation](docs/ssh-and-aliases.md).

Documentation
-------------

[](#documentation)

### User Guides

[](#user-guides)

- [Update Commands](docs/update-commands.md) - Detailed guide to the enhanced update functionality
- [Self-Update](docs/self-update-guide.md) - Update the Phar install or use Composer for Packagist installs
- [List Commands](docs/list-commands.md) - Pagination and filtering for list commands
- [SSH and Aliases](docs/ssh-and-aliases.md) - Remote command execution and aliases
- [Internal API](docs/internal-api.md) - Programmatic usage and extending the CLI

### Developer Guides

[](#developer-guides)

- [Running Tests](docs/running-tests.md) - Guide to running the test suite
- [Debugging Setup](docs/debugging-setup.md) - VS Code debugging configuration
- [Code Style Guide](docs/code-style-guide.md) - Coding standards and PHP\_CodeSniffer setup
- [Medium-Term Enhancements](docs/medium-term-enhancements.md) - Centralized error messages, field mappings, and metadata registry

### Project Planning

[](#project-planning)

- [TODO Priority List](docs/todo-priority-list.md) - Prioritized list of technical debt items
- [GitHub Issues to Create](docs/github-issues-to-create.md) - Major initiative issue templates
- [Type Declarations Progress](docs/type-declarations-progress.md) - Tracking type hint implementation

Bash Completion
---------------

[](#bash-completion)

To enable bash completion, add the following to your `.bashrc` or `.bash_profile`:

```
source /path/to/modx_completion.sh
```

Building the PHAR
-----------------

[](#building-the-phar)

To build the PHAR file:

```
composer install --no-dev
box compile
```

This will create a `modx-cli.phar` file in the root directory.

Development
-----------

[](#development)

### Code Quality

[](#code-quality)

This project follows PSR-12 coding standards. Check your code style:

```
# Check code style
composer cs:check

# Automatically fix code style issues
composer cs:fix
```

### Git Hooks

[](#git-hooks)

Set up the local git hooks to keep `VERSION` in sync when pushing tags:

```
git config core.hooksPath .githooks
chmod +x .githooks/pre-push scripts/release.sh
```

### Running Tests

[](#running-tests)

```
# Run all tests
composer test

# Run unit tests only
composer test:unit

# Run integration tests only
composer test:integration
```

See [Running Tests](docs/running-tests.md) for more details.

### Static Analysis

[](#static-analysis)

This project uses PHPStan for static analysis:

```
# Run static analysis
composer analyse

# Generate baseline for existing issues
composer analyse:baseline
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Before contributing, please:

1. Read the [Code Style Guide](docs/code-style-guide.md)
2. Ensure your code passes `composer cs:check`
3. Add tests for new functionality
4. Update documentation as needed

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance90

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~28 days

Recently: every ~17 days

Total

14

Last Release

47d ago

PHP version history (3 changes)0.1.0-alphaPHP &gt;=7.4

v0.6.0-alphaPHP &gt;=8.0

0.7.0-betaPHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/29bdfee60b3c3d499a340714b21c98ad4148dc3c982cf96e02b6fb9d5a7087fd?d=identicon)[finetuned](/maintainers/finetuned)

---

Top Contributors

[![Finetuned](https://avatars.githubusercontent.com/u/581290?v=4)](https://github.com/Finetuned "Finetuned (348 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (5 commits)")

---

Tags

clishellmodx

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/finetuned-modx-cli/health.svg)

```
[![Health](https://phpackages.com/badges/finetuned-modx-cli/health.svg)](https://phpackages.com/packages/finetuned-modx-cli)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19562.3M1.3k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[crunzphp/crunz

Schedule your tasks right from the code.

2292.0M6](/packages/crunzphp-crunz)[n98/magerun2

Tools for managing Magento projects and installations

928244.3k6](/packages/n98-magerun2)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
