Download the PHP package mcustiel/typed-php without Composer

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

TypedPhp

Immutable Object representation for PHP primitive types and Typed Arrays in PHP.

Build Status Code Coverage Scrutinizer Code Quality

Motivations

In PHP versions 5.5 and 5.6 type hinting is supported for classes and arrays, but not for scalar types. In PHP version 7, type hinting for scalar types is supported, but not typed arrays. So I created object wrappers for scalar types that can be used in PHP 5 and also typed arrays that can be used in PHP7. These objects can be extended to create your own ValueObjects suitable for your domain.

Installation

Composer

How to use

All wrappers implement Primitive interface:

Also all of them return themselves as string, through implementation of __toString magic method. So you can echo them directly.

Primitives

Arrays:

There are two base types:

PrimitivesArray

PrimitivesArray object allows a collection of variables an internal PHP type. And there are already three classes using it:

All of them are constructed with an array as argument. If there is a value in the array of a type that is not correct, an exception will be thrown.

ObjectsArray

This type allows a collection of instances of a given class. An example to create a type for this is as follow:

That's it, you have an array type that accepts only Foo objects. In your code you can use any FooArray object as a regular array.

If there are classes that extend Foo, FooArray will allow them, so polymorphism is supported.

Immutable arrays

For each array type provider there is an immutable version, that allows to be created with a set of values and is not allowed to change.

Flyweight implementation

A basic flyweight pattern implementation is provided. It will return the exact same value object on multiple calls:

In this example $a and $b reference the exact same instance of IntegerValue.


All versions of typed-php with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
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 mcustiel/typed-php contains the following files

Loading the files please wait ....