PHPackages                             mc0de/console-timer - 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. mc0de/console-timer

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

mc0de/console-timer
===================

A trait for tracking execution time in Laravel console commands

1.0.3(1y ago)14404MITPHPPHP ^8.1

Since Apr 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mc0de/console-timer)[ Packagist](https://packagist.org/packages/mc0de/console-timer)[ RSS](/packages/mc0de-console-timer/feed)WikiDiscussions main Synced 3w ago

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

Laravel Console Timer
=====================

[](#laravel-console-timer)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d0698695d65bda3949c370b23fb59edd19be91be1493f1fec76896c02a7106d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d633064652f636f6e736f6c652d74696d65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mc0de/console-timer)[![Total Downloads](https://camo.githubusercontent.com/9884e0e834e0d6fe08ecb4539f8cc9b36890ed138b89f96ff1825feafa8cff53/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d633064652f636f6e736f6c652d74696d65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mc0de/console-timer)[![License](https://camo.githubusercontent.com/72c30d7efceb296a51b529749cfd5ae22ae7c933e0bdead029c9cbd13d8e9445/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d633064652f636f6e736f6c652d74696d65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mc0de/console-timer)

A simple trait that adds execution time tracking to your Laravel console commands. Useful for:

- Tracking how long your commands take to run
- Measuring specific operations within commands
- Debugging slow operations
- Getting timing feedback during long-running processes

[![Console Timer](https://private-user-images.githubusercontent.com/8727992/438390898-ac7ae2e3-5493-4aa9-ba96-e4335aac1614.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODAyNzQzODksIm5iZiI6MTc4MDI3NDA4OSwicGF0aCI6Ii84NzI3OTkyLzQzODM5MDg5OC1hYzdhZTJlMy01NDkzLTRhYTktYmE5Ni1lNDMzNWFhYzE2MTQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDYwMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA2MDFUMDAzNDQ5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmQyOWJlM2VhMjQzM2IyZmZlZTA4NWI1YTA3MmFhYWMyZmUxYWFkNGU4MDFjNjk5YTEyMjlmNmNkODc3YmM3NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.vshtJcKXhws9VBWdp8DUT_7-vGADUvH_nvFa4cQcaes)](https://private-user-images.githubusercontent.com/8727992/438390898-ac7ae2e3-5493-4aa9-ba96-e4335aac1614.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODAyNzQzODksIm5iZiI6MTc4MDI3NDA4OSwicGF0aCI6Ii84NzI3OTkyLzQzODM5MDg5OC1hYzdhZTJlMy01NDkzLTRhYTktYmE5Ni1lNDMzNWFhYzE2MTQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDYwMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA2MDFUMDAzNDQ5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmQyOWJlM2VhMjQzM2IyZmZlZTA4NWI1YTA3MmFhYWMyZmUxYWFkNGU4MDFjNjk5YTEyMjlmNmNkODc3YmM3NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.vshtJcKXhws9VBWdp8DUT_7-vGADUvH_nvFa4cQcaes)

Features
--------

[](#features)

- Track total command execution time
- Measure individual operations
- Get operation return values
- Format durations in a readable way
- Start/stop measurements manually or with closures

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

[](#requirements)

- PHP ^8.1
- Laravel 10.x|11.x|12.x

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

[](#installation)

```
composer require mc0de/console-timer
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Add the trait to your command and wrap operations you want to measure:

```
use Mc0de\ConsoleTimer\ConsoleTimer;
use Illuminate\Console\Command;

class YourCommand extends Command
{
    use ConsoleTimer;

    public function handle()
    {
        $this->startCommandTimer();

        $this->measure('Processing items', function () {
            // Your processing logic
        });

        $this->displayCommandTime();
    }
}
```

### Getting Return Values

[](#getting-return-values)

```
$result = $this->measure('Fetching data', function () {
    return ['data' => 'value'];
});

// $result contains ['data' => 'value']
```

### Manual Timing

[](#manual-timing)

For operations that span multiple methods:

```
public function handle()
{
    $this->startCommandTimer();

    $this->startMeasure('Processing items');
    $this->processItems();
    $this->finishMeasure();

    $this->displayCommandTime();
}

protected function processItems()
{
    // This method is part of the measured operation
}
```

Example Output
--------------

[](#example-output)

```
  19:17:45 Fetching CRM data ........................................ 1.92s ✓
  19:17:47 Syncing product catalog .................................. 2.34s ✓
  19:17:49 Processing user data ..................................... 394ms ✓
  19:17:49 Running ML recommendations ............................... 3.76s ✓
  19:17:53 Generating sales report .................................. 899ms ✓
  19:17:54 Creating analytics dashboard ............................. 5.26s ✓
  19:17:59 Saving to database ....................................... 389ms ✓

  Completed in 14.99s

```

Methods
-------

[](#methods)

- `startCommandTimer()` - Start tracking total command time
- `measure(string $message, Closure $callback)` - Measure an operation and show progress
- `startMeasure(string $message)` - Start measuring without a closure
- `finishMeasure()` - End the current measurement
- `displayCommandTime()` - Show total command execution time

License
-------

[](#license)

MIT License - see [LICENSE.md](LICENSE.md)

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance46

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

420d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8727992?v=4)[David Lun](/maintainers/mc0de)[@mc0de](https://github.com/mc0de)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/mc0de-console-timer/health.svg)

```
[![Health](https://phpackages.com/badges/mc0de-console-timer/health.svg)](https://phpackages.com/packages/mc0de-console-timer)
```

###  Alternatives

[illuminate/console

The Illuminate Console package.

13045.3M6.2k](/packages/illuminate-console)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[spatie/laravel-flare

Send Laravel errors to Flare

111.2M6](/packages/spatie-laravel-flare)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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