Download the PHP package hamcrest/hamcrest-php without Composer

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

This is the PHP port of Hamcrest Matchers

tests

Hamcrest is a matching library originally written for Java, but subsequently ported to many other languages. hamcrest-php is the official PHP port of Hamcrest and essentially follows a literal translation of the original Java API for Hamcrest, with a few Exceptions, mostly down to PHP language barriers:

  1. instanceOf($theClass) is actually anInstanceOf($theClass)

  2. both(containsString('a'))->and(containsString('b')) is actually both(containsString('a'))->andAlso(containsString('b'))

  3. either(containsString('a'))->or(containsString('b')) is actually either(containsString('a'))->orElse(containsString('b'))

  4. Unless it would be non-semantic for a matcher to do so, hamcrest-php allows dynamic typing for it's input, in "the PHP way". Exception are where semantics surrounding the type itself would suggest otherwise, such as stringContains() and greaterThan().

  5. Several official matchers have not been ported because they don't make sense or don't apply in PHP:

    • typeCompatibleWith($theClass)
    • eventFrom($source)
    • hasProperty($name) **
    • samePropertyValuesAs($obj) **
  6. When most of the collections matchers are finally ported, PHP-specific aliases will probably be created due to a difference in naming conventions between Java's Arrays, Collections, Sets and Maps compared with PHP's Arrays.

** [Unless we consider POPO's (Plain Old PHP Objects) akin to JavaBeans]

Usage

Hamcrest matchers are easy to use as:

Alternatively, you can use the global proxy-functions:

:warning: NOTE: the global proxy-functions aren't autoloaded by default, so you will need to load them first:

For brevity, all of the examples below use the proxy-functions.

Documentation

A tutorial can be found on the Hamcrest site.

Available Matchers

Array

Collection

Core

Object

Numbers

String

Type-checking

XML


All versions of hamcrest-php with dependencies

PHP Build Version
Package Version
Requires php Version ^5.3|^7.0|^8.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 hamcrest/hamcrest-php contains the following files

Loading the files please wait ....