Download the PHP package samsara/newton without Composer

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

Newton

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License

This project is unit tested against 5.6.X and 7.X, and merges are not accepted unless the tests pass on both.

Installation

To install, simply require the package using composer:

composer require samsara/newton "1.*"

Or include it in your composer.json file:

The project namespace is Samsara\Newton\*. You can view the project on Packagist.

Usage

There are many ways to use this package. The preferred way involves instantiating the UnitComposition class and using it as a factory.

In order to allow new unit classes which extend Quantity to work with the UnitComposition class, it was necessary to force instantiation of it. This is explained in further detail in the Extending section.

This also means that if you directly instantiate a unit, you must inject a UnitComposition instance.

You can also add unit of different types.

The MathProvider has static methods which allow you to perform math operations using the BC Math extension. This is used internally in the project as we might very easily exceed the PHP_INT_MAX limit during unit conversions. It also provides several random functions, including a gaussianRandom() method.

The PhysicsProvider has static methods which implement some common physics equations using the correct unit classes.

An interesting, non-physics use for something like this library is to determine how many times a given server can execute a loop per second. For instance:

Extending

Adding new units is relatively easy. You must first make your unit class, and this class must extend Samsara\Newton\Core\Quantity. This class must define a set of units in the $units property (where it defines the index for $rates), and then define the relative conversion rates between them.

All of the conversions must be in terms of the native unit, which is defined in the property $native.

Example

Then, in the calling context, you must prepare the UnitComposition class with the definitions of what types of units this custom unit contains. This allows the UnitComposition class to automatically use your custom class in multiply and divide operations when it is appropriate to do so.

Only the instance of UnitComposition prepared in the way outlined above, with a call to addUnit(), will understand how to automatically return an instance of MyUnit(). Because of this, it is suggested that you treat the UnitComposition class as a service, and use a single instance of it within your application.

Contributing

Please ensure that pull requests meet the following guidelines:

For more information, please see the section on Contributing


All versions of newton with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
ircmaxell/random-lib Version 1.1.*
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 samsara/newton contains the following files

Loading the files please wait ....