Download the PHP package mtownsend/progress without Composer

On this page you can find all versions of the php package mtownsend/progress. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package progress

A PHP package to determine progress.

Purpose

Walking your users through a process is important for your web app. You want your users to know what you expect of them or a list of requirements that they need to complete.

This progress package is a simple way of taking multiple steps in a process and using them to create a progression system. You can define your steps through an expressive and simple API and let this package handle the heavy lifting. The result is a delightfully easy to use steps-and-progression system.

Simple overview

To keep things easy, this package only introduces 2 classes: Progress and Step. The Progress class can accept one or more Steps. Each Step class is self contained with the data it is evaluating and chainable methods that evaluate the data in a truth test format.

This package utilizes the beberlei/assert library under the hood to handle all of the truthy statements that the Step class uses to evaluate against the data it contains. Every assertion method from beberlei/assert is chainable on the Step class. You can find a list of methods below in the documentation.

Installation

Install via composer:

This package is designed to work with any PHP 7.4+ application.

Quick start

Using the class

Here is an example of the most basic usage:

The Progress class can accept a single Step class or many.

Additionally, if you prefer global helpers, this package auto loads two global helper functions: progress() and step(). They instantiate each class and accept the exact same arguments. Using the global helpers can reduce your lines of code and eliminate the need to use the Progress and Step class at the top of your php script - but not all developers prefer global helpers, so it is entirely optional.

The Progress class arguments and methods

The Progress class contains 1 optional constructor argument:

The $steps argument can be a single instance of \Mtownsend\Progress\Step, multiple instances as their own argument, or an array of Step classes.

However, you can instantiate the Progress class without supplying any arguments.

Methods

add(mixed $steps) Functions exactly the same as the constructor arguments. You can pass a single Step, array or multiple instances.

get() retrieves the overall progress of your steps. Once it has been called it simply returns the evaluated data. If you want to reuse the class for more progress calculation you will need to instantiate a new Progress class to do so.

toJson() returns the result of the Progress class in valid json.

toObject() returns the result of the Progress class as a standard PHP object.

Magic Properties

If you want to access the results of the Progress class without accessing the array of results directly, you can use magic properties that correspond to the key name of the result you want to retrieve.

For example consider the following:

The Step class arguments and methods

Arguments

The Step class contains 2 constructor arguments:

The $data argument can be anything you wish to evaluate - data from your database, form submission, or other.

$name is completely optional, but it can be used to keep track of the step or a label for the step. If you do not assign a name to your Step, it will not appear in the complete_step_names or incomplete_step_names keys, but the failure or success will still be calculated.

Step arguments and methods

Methods

Since the Step class wraps around the beberlei/assert library, you can chain any of the Assertion class methods directly on the Step class. To see a full list you can view them directly on the library's readme, but almost every method you would use has been listed below:

The Progress class handles checking if a Step has passed or failed, but in the event you wish to manually check if a Step has failed you can call $step->passed() which will return a boolean.

Error handling

In the event you do not supply any Stepss to a Progress instance and attempt to run the ->get() method, a \Mtownsend\Progress\Exceptions\NoStepsException will be thrown.

Credits

Testing

You can run the tests with:

License

The MIT License (MIT). Please see License File for more information.


All versions of progress with dependencies

PHP Build Version
Package Version
Requires php Version ~7.4|~8.0
beberlei/assert Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mtownsend/progress contains the following files

Loading the files please wait ....