Download the PHP package batrox/distance without Composer

On this page you can find all versions of the php package batrox/distance. 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 distance

Distance Helper Build Status

 About

This Distance Helper package contains a tested PHP Value Object which makes working with, comparing, converting and formatting distances (meters, kilometers and steps) easy and fluent.

The inspriation for the package came from PHP helpers like Carbon, and an effort to refactor the code behind the virtual workplace walking challenge system Big Team Challenge.

Installation

You can pull in this package through composer

The package (particularly configuration) is designed to work with Laravel 5. Include our custom service provider within config/app.php:

Usage

To create a new distance you, simply new-up an instance of the Distance class.

The default distance is meters, so ommitting the second (optional) constructor argument will default to meters

API

Converting

You can convert a distance object to a new unit using the to methods.

The following methods are built-in:

If you just want to get the conversion, without changing the object, you can use the asUnit method.

Rounding

Each unit has it's own decimal precision, and you can get the rounded format by using the round method.

Comparison

Empty / zero

Value Comparison

Percentage Of

By default, the percentage is capped at 100, but passing false as the second parameter will always return the real percentage.

Modifying

You can add or subtract distances

Formatting

Using PHP's magic __toString() method, echo-ing or casting the object itself will round and use the number_format function to return a string-representation of the value.

You can change the default formatting options to include/omit the comma and the unit suffix. Publish the config file using

You can also use the toStringWithSuffix method to force the suffix on the end, for example:

Contributing

Please submit improvements and fixes :)

Changelog

Look at the CHANGELOG.md for this package.

Author

David Rushton - Team Challenge Apps Ltd


All versions of distance with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2|^8.0.2
illuminate/support Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.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 batrox/distance contains the following files

Loading the files please wait ....