Coder Social home page Coder Social logo

php-indicators's Introduction

Latest Stable Version Total Downloads Travis CLI License

Indicator library

PHP Indicators for command line interface (CLI)

Dependency notice

To run this library you must have php 7.1 or greater.

Installation

This library can be found on packagist and installed using composer:

composer require ed9/php-indicators

Loading indicator

Enable loading indicator for your CLI application. View the full example usage code at: example.

loading preview

Indicator methods:

Initiate new loading instance by overwriting the total row count, the bar length and auto step increment straight from the constructor.

$loading = new \Edward\Indicator\Loading(100, 30, true);

Overwrite the bar length on demand

$loading->setBarLength(30);

Overwrite the total row count on demand

$loading->setTotal(100);

Overwrite the necessity for steps to be incremented on every ping automatically. If set to false, the script will not increment when ping is called but will rely on you to update via setCurrent()

$loading->setAutoIncrement(true);

You can change the current step even if auto increment is enabled, it will follow your input.

$loading->setCurrent(0);

Run ping on every row you are processing and it will output the string into your console if no argument is provided.

$loading->ping();

Alternatively you can provide a callable argument to process the output yourself.

  • The variables you will receive in the argument:
  • string - A formatted string that can be outputted
  • process.current - Integer representing current step
  • process.total - Integer representing total row count
  • percentageCompleted - Float represented completion percentage
  • elapsed.value - Time unit elapsed since initial ping
  • elapsed.format - Time format elapsed since initial ping (seconds,minutes,hours)
  • eta.value - Estimated time unit until completion
  • eta.format - Estimated time format until completion (seconds,minutes,hours)
$loading->ping(function ($info) use ($loading) {
    print $info['string'];
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.