PHPackages                             abdukhaligov/nova-command-runner - 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. abdukhaligov/nova-command-runner

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

abdukhaligov/nova-command-runner
================================

Laravel Nova tool for running Artisan and bash(shell) commands.

v4.4.7(1y ago)08MITPHPPHP &gt;=7.4

Since Jan 28Pushed 1y agoCompare

[ Source](https://github.com/Abdukhaligov/nova-command-runner)[ Packagist](https://packagist.org/packages/abdukhaligov/nova-command-runner)[ RSS](/packages/abdukhaligov-nova-command-runner/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Laravel Nova tool for running Artisan &amp; Shell commands
==========================================================

[](#laravel-nova-tool-for-running-artisan--shell-commands)

[![Latest Version on Packagist](https://camo.githubusercontent.com/840424fbbfa869dca7390705d9b72bf5e1a533a65d52936b8a611927ad2213f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73746570616e656e6b6f332f6e6f76612d636f6d6d616e642d72756e6e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stepanenko3/nova-command-runner)[![Total Downloads](https://camo.githubusercontent.com/5a83c4077d49b6aac21e96bfd5a093024fb26f75e7cedf17a066c589265eda27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746570616e656e6b6f332f6e6f76612d636f6d6d616e642d72756e6e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stepanenko3/nova-command-runner)[![License](https://camo.githubusercontent.com/3db0daae6ad06bf6d0b539b400194e409803b15b178013b84fb53f632b494cc4/68747470733a2f2f706f7365722e707567782e6f72672f73746570616e656e6b6f332f6e6f76612d636f6d6d616e642d72756e6e65722f6c6963656e7365)](https://packagist.org/packages/stepanenko3/nova-command-runner)

[![screenshot of the command runner tool](screenshots/tool.png)](screenshots/tool.png)

Description
-----------

[](#description)

This [Nova](https://nova.laravel.com) tool lets you run artisan and bash commands directly from nova.

> This is an extended version of the original package [Nova Command Runner](https://github.com/guratr/nova-command-runner) by [guratr](https://github.com/guratr)

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

[](#requirements)

- `php: >=8.0`
- `laravel/nova: ^4.0`

Features
--------

[](#features)

- ⌨️ Run predefined artisan and shell commands
- 📝 Run custom artisan and shell commands
- 📄 Use variables while running commands
- 🙋‍♂️ Prompt the user to specify optional flags while running commands
- 📄 Use predefined values for variables using a select box or prompt the user to enter a value for the variable.
- 📖 Keep track of command run history
- 💾 No database changes required. Everything is managed from a single config file.
- 🕔 Queue long running commands
- ✅ Support command progressbar
- 📱 Responsive
- 🕶 Dark mode

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

[](#installation)

You can install the nova tool in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```
composer require stepanenko3/nova-command-runner
```

Next up, you must register the tool with Nova. This is typically done in the `tools` method of the `NovaServiceProvider`.

```
// in app/Providers/NovaServiceProvder.php

// ...

public function tools()
{
    return [
        // ...
        new \Stepanenko3\NovaCommandRunner\CommandRunnerTool,
    ];
}
```

Publish the config file:

```
php artisan vendor:publish --provider="Stepanenko3\NovaCommandRunner\ToolServiceProvider"
```

Add your commands to `config/nova-command-runner.php`

Usage
-----

[](#usage)

Click on the `"Command Runner"` menu item in your Nova app to see the tool.

Configuration
-------------

[](#configuration)

All the configuration is managed from a single configuration file located in `config/nova-command-runner.php`

### Adding Commands

[](#adding-commands)

All the commands which needs to be easily accessible should be defined in the `commands` array in the configuration file.

#### Command Options

[](#command-options)

- run : command to run (E.g. route:cache)
- type : button class (primary, secondary, success, danger, warning, info, light, dark, link)
- group: Group name (optional)
- variables : Array of variables used in the command(optional)
- command\_type : Type of the command.(artisan or bash. Default artisan)
- flags : Array of optional flags for the command(optional)
- output\_size: crops output of the given command to the specified number of lines
- timeout: updates the timeout limit for the given queued command

#### Examples

[](#examples)

```
'commands' => [

    // Basic command
    'Clear Cache' => [
        'run' => 'cache:clear',
        'type' => 'danger',
        'group' => 'Cache',
    ],

    // Bash command
    'Disk Usage' => [
        'run' => 'df -h',
        'type' => 'danger',
        'group' => 'Statistics',
        'command_type' => 'bash'
    ],

    // Command with variable
    'Clear Cache' => [
        'run' => 'cache:forget {cache key}',
        'type' => 'danger',
        'group' => 'Cache'
    ],

    // Command with advanced variable customization
    'Clear Cache' => [
        'run' => 'cache:forget {cache key}',
        'type' => 'danger',
        'group' => 'Cache',
        'variables' => [
            [
                'label' =>  'cache key' // This needs to match with variable defined in the command,
                'field' => 'select' // Allowed values (text,number,tel,select,date,email,password),
                'options' => [
                    'blog-cache' => 'Clear Blog Cache',
                    'app-cache' => 'Clear Application Cache'
                ],
                'placeholder' => 'Select An Option'
            ]
        ]
    ],

    // Command with flags
    'Run Migrations' => [
        'run' => 'migrate --force',
        'type' => 'danger',
        'group' => 'Migration',
    ],

    // Command with optional flags
    'Run Migrations' => [
        'run' => 'migrate',
        'type' => 'danger',
        'group' => 'Migration',
        'flags' => [
            // These optional flags will be prompted as a checkbox for the user
            // And will be appended to the command if the user checks the checkbox

            '--force' => 'Force running in production'
        ]
    ],

    // Command with help text
    'Run Migrations' => [
        'run' => 'migrate --force',
        'type' => 'danger',
        'group' => 'Migration',

        // You can also add html for help text.
        'help' => 'This is a destructive operation. Proceed only if you really know what you are doing.'
    ],

    // Queueing commands
    'Clear Cache' => [
        'run' => 'cache:clear --should-queue',
        'type' => 'danger',
        'group' => 'Cache',
    ],

    // Queueing commands on custom queue and connection
    'Clear Cache' => [
        'run' => 'cache:clear --should-queue --cr-queue=high --cr-connection=database',
        'type' => 'danger',
        'group' => 'Cache',
    ],
],
```

### Command with Progress bar

[](#command-with-progress-bar)

Create Artisan command with progress bar. For example:

```
