Download the PHP package subiabre/phpmetro without Composer

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

PHPMetro

Streamlined statistical sampling and analysis of results.

PHPMetro logo

License Latest Stable Version CI codecov Total Downloads

PHPMetro provides the foundation to perform sampling and analysis of data in a PHPUnit-like fashion, aiming to make it as easy as possible for PHP developers to compose analysis suites and get statistical results.

  1. About
  2. Requirements
  3. Installation
  4. Configuration
  5. Usage (basic tutorial)
  6. Support

About

I created this package on winter 2019 because I was working on a project that required me to not only perform unit and functional tests of my code, but to also create and perform several statistical analyses of my code. PHPMetro was my response to that requirement.

WARNING: Despite the origin of this project being that of a professional environment, it's not granted to be suitable for all production environments.

Requirements

*Package should be compatible with older versions of PHP down to 5.x, but it's not granted.

Installation

PHPMetro is distributed on packagist.

Once installed you'll get the phpmetro binary in your bin folder, by default vendor/bin. After installation you'll want to run composer suggests subiabre/phpmetro to see some more libraries you'll find useful when writing your analyses, as PHPMetro only contains a basic toolset for describing analysis cases with an specific workflow, and a runner to perform all our analyses based on a given configuration.

Configuration

PHPMetro needs to be fed a .xml config file on run. This file will tell where to search for our Analysis classes and how to run them.

Getting the template configuration

Easiest way is to copy to the root of your project the example config file at your vendor folder:

The binary will automatically search for any phpmetro.xml at the root folder and load it unless you specify a location, you can use that to use and run several different configurations and suites.

Configuring

The .xml config file specifies general run directives for the PHPMetro binary as well as defines the analyses by suite groups.

The default file can be environment specific: phpmetro.xml.local will override phpmetro.xml.dist and this will override phpmetro.xml.

  1. Configuring PHPMetro
  2. Configuring Suites

Configuring PHPMetro

The two attributes you see are required and they mean:

There are no more run configurations. The runner will automatically fetch files from the suites you define. You can set more configurations per suite.

Configuring Suites

Suites must be inside the <suites> tag. Each suite accepts the following attributes:

NOTE: Suffixes don't necessarily have to include the '.php' file extension. In fact the suite right-trims it from the suffix.

Inside each suite there must be two more tags specificating:

NOTE: You must adhere to the PSR-4 specification when filenaming your Analyses. If you have an Analysis with the namespace MyApp\Tests\Foo\BarAnalysis, for this class to be properly identified by PHPMetro it will have to be located at tests/Foo/BarAnalysis.php.

Usage

Say you have your own random number generator, MyApp\RandomNumber, and want to see some statistics about it. PHPMetro is your package for that! Let's put it under "Analysis".

Creating an Analysis class

An Analysis is an special class that extends from AnalysisCase and contains a set up with samples and several tests over the samples.

Congratulations, you just created your very first Analysis. But just like that it's pretty much useless. Now you need to add some Samples to your Analysis.

Adding Sample data

A Sample is an special array inside the AnalysisCase class that contains sample data from a given set of functions. On your Analysis class add:

To add data to a sample we use the addSample function, this function takes exactly 3 parameters:

NOTE: Function calls that don't specify a return a value will not generate a Sample.

The setUp method is required by the AnalysisInterface. All analyses must implement this method with the purpose of being run before test methods in the Analysis.

You can call to addSample anywhere inside your class methods actually, this function will hold the execution of the runner until it finishes adding records. However it is recommended that you add your Samples on set up for performance and maintainability reasons.

NOTE: Unlike other testing frameworks and libraries, PHPMetro will run the method setUp only once before running all tests instead of once before each test.

Now that there is Sample data we can start performing some calculations on it. For that you must simply just add Test methods in your class.

Writing Test methods

A Test is an special class method inside your Analysis class that performs some kind of calculation and returns the result. These methods must match the regular expression test[A-Za-z09]* and return a basic data type.

WARNING: Tests that return complex data types such as arrays or objects that can't be typecasted to strings will throw an error exception and stop the PHPMetro run.

NOTE: Tests that don't specify a return type will be ignored and not executed.

For example, we want to test what's the median average of the generated random numbers.

Our Analysis class should look like this:

To calculate it we first accessed the sample we added on set up with getSample, and then passed it to MathPHP's Average to calculate the median for us.

You can keep writing more Tests to calculate different things with your Samples. Write Tests as you need them.

Finally, to run the Analyses just run the binary:

Your Tests results should start appearing on your console screen.

PHPMetro on console

You can check more usage examples inside tests/Self folder. Which is the self analysis suite described in tests/phpmetro.xml.

Support

You can support this project by contributing to open issues or creating pull requests to improve/fix existing code. Contributors are welcome.

If you liked this package give it a star or tell a friend about it.

If you have any doubt or commentary, contact me.

Thank you!


All versions of phpmetro with dependencies

PHP Build Version
Package Version
Requires symfony/console Version ^5.1
sebastian/version Version 2.0.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 subiabre/phpmetro contains the following files

Loading the files please wait ....