PHPackages                             plusinfolab/artisan-batch - 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. plusinfolab/artisan-batch

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

plusinfolab/artisan-batch
=========================

Run multiple artisan commands in defined batches or recipes.

10PHP

Since Sep 25Pushed 3mo agoCompare

[ Source](https://github.com/plusinfolab/artisan-batch)[ Packagist](https://packagist.org/packages/plusinfolab/artisan-batch)[ RSS](/packages/plusinfolab-artisan-batch/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

Artisan Batch
=============

[](#artisan-batch)

A Laravel package for running multiple Artisan commands in sequence using predefined recipes. Perfect for deployment scripts, local development setup, and maintenance operations.

Features
--------

[](#features)

- =€ Execute multiple Artisan commands with a single command
- =Ë Predefined recipes for common operations (deploy, cache clearing, testing, etc.)
- ™� Customizable configuration with environment-specific settings
- = Dry-run mode to preview commands before execution
- =Ê JSON output for CI/CD integration
- =á� Error handling with configurable stop-on-failure behavior
- =Ý Detailed logging and execution statistics
- ñ� Command execution timing
- =� Protection for destructive commands in production

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

[](#installation)

1. Install the package via Composer:

```
composer require plusinfolab/artisan-batch
```

2. Publish the configuration file:

```
php artisan vendor:publish --provider="PlusInfoLab\ArtisanBatch\ArtisanBatchServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

### List Available Recipes

[](#list-available-recipes)

```
php artisan batch:list
```

For detailed view:

```
php artisan batch:list --detailed
```

For JSON output:

```
php artisan batch:list --json
```

### Run a Recipe

[](#run-a-recipe)

```
php artisan batch:run
```

### Examples

[](#examples)

#### Deploy to Production

[](#deploy-to-production)

```
php artisan batch:run deploy
```

#### Local Development Setup

[](#local-development-setup)

```
php artisan batch:run local-setup
```

#### Clear All Caches

[](#clear-all-caches)

```
php artisan batch:run cache-clear
```

#### Database Reset (Local)

[](#database-reset-local)

```
php artisan batch:run local-reset
```

### Advanced Usage

[](#advanced-usage)

#### Dry Run (Preview Commands)

[](#dry-run-preview-commands)

```
php artisan batch:run deploy --dry
```

#### Continue on Failure

[](#continue-on-failure)

```
php artisan batch:run deploy --no-stop
```

#### Verbose Output

[](#verbose-output)

```
php artisan batch:run deploy --verbose
```

#### JSON Output (for CI/CD)

[](#json-output-for-cicd)

```
php artisan batch:run deploy --json
```

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

[](#configuration)

### Publish Configuration

[](#publish-configuration)

After publishing, you'll find the configuration at `config/batch.php`.

### Define Custom Recipes

[](#define-custom-recipes)

```
'recipes' => [
    'my-custom-recipe' => [
        'cache:clear',
        'migrate --force',
        'queue:restart',
    ],
],
```

### Global Settings

[](#global-settings)

- `stop_on_failure`: Stop execution when a command fails (default: true)
- `command_timeout`: Timeout for each command in seconds (default: 300)
- `enable_logging`: Enable detailed logging (default: true)
- `log_file`: Log file path relative to storage/logs (default: 'artisan-batch.log')

### Environment-Specific Settings

[](#environment-specific-settings)

```
'environments' => [
    'production' => [
        'stop_on_failure' => true,
        'confirm_destructive' => true,
        'default_recipes' => ['deploy', 'optimize']
    ],
],
```

Built-in Recipes
----------------

[](#built-in-recipes)

RecipeDescriptionEnvironment`deploy`Production deployment with migration and cachingProduction`local-setup`Local development setup with migration and seedingLocal`local-reset`Complete database reset with fresh migrationLocal`cache-clear`Clear all application cachesAny`optimize`Optimize for production environmentProduction`maintenance-on`Enable maintenance modeProduction`maintenance-off`Disable maintenance mode and clear cachesProduction`test`Run tests with coverage reportLocal`health-check`Check application health statusAnyOutput Examples
---------------

[](#output-examples)

### Standard Output

[](#standard-output)

```
=€ Running batch 'deploy'...
Configuration: EXECUTE | Stop on failure: YES
============================================================
1. cache:clear
Output: Application cache cleared successfully.
Time: 15.23ms | Exit: 0
----------------------------------------
2. config:clear
Output: Configuration cache cleared successfully.
Time: 8.45ms | Exit: 0
----------------------------------------
...
============================================================
� Batch 'deploy' completed successfully!
Summary: 8 successful, 0 failed, 0 skipped

```

### JSON Output

[](#json-output)

```
{
  "recipe": "deploy",
  "dry_run": false,
  "start_time": "2024-01-15T10:30:00.000Z",
  "commands": [
    {
      "index": 1,
      "command": "cache:clear",
      "status": "success",
      "output": "Application cache cleared successfully.",
      "exit_code": 0,
      "execution_time": 15.23
    }
  ],
  "summary": {
    "total": 8,
    "successful": 8,
    "failed": 0,
    "skipped": 0
  },
  "end_time": "2024-01-15T10:32:15.000Z",
  "completed": true
}
```

CI/CD Integration
-----------------

[](#cicd-integration)

### GitHub Actions Example

[](#github-actions-example)

```
- name: Deploy to Production
  run: |
    php artisan batch:run deploy --json > deploy_output.json

- name: Verify Deployment
  run: |
    jq -e '.completed == true and .summary.failed == 0' deploy_output.json
```

### Laravel Forge Integration

[](#laravel-forge-integration)

```
# Deploy script for Forge
php artisan down
php artisan batch:run deploy
php artisan up
```

Security Considerations
-----------------------

[](#security-considerations)

- Destructive commands are flagged and may require confirmation in production
- Recipes with `migrate --force` are automatically protected in production environments
- All command execution is logged for audit purposes
- JSON output can be parsed for automated monitoring

Best Practices
--------------

[](#best-practices)

1. **Always test recipes locally**: Use `--dry` to preview commands before running in production
2. **Use environment-specific recipes**: Leverage the environment configuration for different deployment strategies
3. **Monitor execution logs**: Check `storage/logs/artisan-batch.log` for detailed execution history
4. **Implement monitoring**: Use JSON output to integrate with monitoring systems
5. **Version control recipes**: Keep your `config/batch.php` in version control

Troubleshooting
---------------

[](#troubleshooting)

### Command Not Found

[](#command-not-found)

```
php artisan batch:list
```

If you get "command not found", ensure the service provider is properly registered.

### Permission Issues

[](#permission-issues)

Make sure your Laravel application has write permissions to the `storage/logs` directory for logging.

### Recipe Not Found

[](#recipe-not-found)

Check that the recipe name exists in your `config/batch.php` file and run `php artisan batch:list` to see available recipes.

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

[](#contributing)

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance54

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5704ae6235da3734f84e8db1db6e2e10a1a697dfde3643939386e7ccb374a795?d=identicon)[amjpdevp](/maintainers/amjpdevp)

---

Top Contributors

[![amjpdevp](https://avatars.githubusercontent.com/u/113779419?v=4)](https://github.com/amjpdevp "amjpdevp (4 commits)")

### Embed Badge

![Health badge](/badges/plusinfolab-artisan-batch/health.svg)

```
[![Health](https://phpackages.com/badges/plusinfolab-artisan-batch/health.svg)](https://phpackages.com/packages/plusinfolab-artisan-batch)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M19](/packages/consolidation-annotated-command)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)[codedungeon/php-cli-colors

Liven up you PHP Console Apps with standard colors

10210.1M26](/packages/codedungeon-php-cli-colors)

PHPackages © 2026

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