Download the PHP package milantex/tpc without Composer

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

Build Status codecov Code Climate Latest Stable Version Total Downloads License SensioLabsInsight

What are Milantex Typed Property Classes?

This project provides a mechanism to specify types for class properties. Also, property types have additional parameters, such as the regular expression pattern for strings, minimum and maximum value for integers etc. The special setter method handles type checking and will set the given value only if it is valid for the given type and its additional parameters. Check the documentation for an example.

Installation

Using composer in the command line

You can use composer to install the package using the following command from within your project's source directory:

composer require milantex/tpc

Make sure to update your autoloader if needed:

composer dump-autoload -o

Requiring the package as a dependency in composer.json

Add the following code to your composer.json. Here is an example of a composer.json file with the milantex/tpc package required:

Make sure to run the composer command to install dependencies:

composer install

Using it in your project

Make sure that you require the vendor autoload file first.

After that, to create a class with typed properties, it must extend the Milantex\TPC\TypedPropertyClass.

Class properties must be marked as protected (not private) and should never be left as public.

To define the type and add any additional type specific parameters, use the annotation comment.

The type class should be specified using the fully-qualified path, including the namespace and should be set for the @type tag.

Different types provide different parameters. Each parameter should be specified as a tag in the annotation comment.

To create setter methods, use the inherited setProperty method.

Look at the following example of a Student class with a couple of properties with different types, each specifying additional parameters and setter methods for each of the properties.

Now, in another file, create an instance of this class and attempt to set valid and invalid values for each property).

Output:

As you see, the valid values (currently all set using appropriate setters) were assigned to the properties of the $s object.

Now, see what happens when we try to set the forename to a value which is not valid (does not match the pattern defined for this property):

Output:

Note that the forename did not change to "Not a valid name". Instead, it remained "Milan", which was the latest valid value assigned to this property.

Now, some values will be valid and some will not (index and the year of enrolment). The original values will remain unchanged.

Output:

Finally, the DateType class does not just check the format of the date, but also checks if the date is a valid date. Look at the example below:

Output:

As you can see, the previous valid date (April 30th) was unchanged, because the intended date was not a valid date, even though it was in the correct format.

Supported types

Currently, there are only four type classes in the Milantex\TPC\Types namespace. These are:

Milantex\TPC\Types\DateType

The DateType type class is used for properties of type date. The required format is YYYY-MM-DD.

Parameters:

@min

This parameter is used to specify the smallest date that can be set for this property. If not defined, the smallest date is 0000-00-00 at 00:00:00.

@max

This parameter is used to specify the biggest date that can be set for this property. If not defined, the biggest date is 9999-12-31 at 23:59:59.

Milantex\TPC\Types\StringType

The StringType type class is used for properties of type string. Its main feature is the ability to define value validation using regular expressions.

Parameters:

@pattern

This parameter is used to specify the regular expression used to match the intended value for this property. If not defined, the default pattern is /^.$/. The pattern is defined without quotes just like it would be in preg_ functions.

Milantex\TPC\Types\IntType

The IntType type class is used for properties of type integer (or long).

Parameters:

@min

This parameter is used to specify the smallest value that can be set for this property. If not defined, the smallest value is \PHP_INT_MIN.

@max

This parameter is used to specify the biggest value that can be set for this property. If not defined, the biggest value is \PHP_INT_MAX.

Milantex\TPC\Types\FloatType

The FloatType type class is used for properties of type float (or double).

Parameters:

@min

This parameter is used to specify the smallest value that can be set for this property. If not defined, the smallest value is \PHP_FLOAT_MIN.

@max

This parameter is used to specify the biggest value that can be set for this property. If not defined, the biggest value is \PHP_FLOAT_MAX.

Creating custom types

You can create custom type classes. The type class must implement the Milantex\TPC\TypeInterface.

Look at the code for the FloatType type class for an example on how to create your own custom type classes.


All versions of tpc with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.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 milantex/tpc contains the following files

Loading the files please wait ....