Download the PHP package yii1tech/model-typecast without Composer

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

Model Attributes Typecast Extension for Yii 1


This extension provides support for Yii1 Model and ActiveRecord attributes typecast.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build Status

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the "require" section of your composer.json.

Usage

This extension provides support for Yii1 Model and ActiveRecord automatic attributes typecast. It is performed via usage of \yii1tech\model\typecast\TypecastBehavior behavior. It should be attached to \CModel or \CActiveRecord descendant. For example:

Tip: you may leave \yii1tech\model\typecast\TypecastBehavior::$attributeTypes blank - in this case its value will be detected automatically: for ActiveRecord - based on owner DB table schema, for regular model - based validation rules.

In the above example attribute typecasting will be automatically performed in following cases:

For example:

You can manually trigger attribute typecasting anytime invoking \yii1tech\model\typecast\TypecastBehavior::typecastAttributes() method:

JSON Typecasting

This behavior allows automatic conversion of array or traversable objects into JSON string on model saving. For example:

Note: such conversion will take place even, if there is no direct attribute type specification.

You can typecast JSON column value either to plain array or \ArrayObject instance. Plain arrays consume less memory, but writing of its particular internal keys will not work. \ArrayObject allows free operation over internal keys, but you should note that its value always passed by reference.

DateTime Typecasting

This behavior allows automatic conversion of \DateTime instances into ISO datetime string on model saving. For example:

In case you store the dates using integer Unix timestamp, you can use \yii1tech\model\typecast\TypecastBehavior::TYPE_TIMESTAMP for correct conversion. For example:

This extension also supports nesbot/carbon package. In order to convert dates to \Carbon\Carbon you should use following types:

Custom Typecasting

You may specify any custom typecasting for the attribute using a callable as a type specification at \yii1tech\model\typecast\TypecastBehavior::$attributeTypes. For example:


All versions of model-typecast with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
yiisoft/yii Version ~1.1.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 yii1tech/model-typecast contains the following files

Loading the files please wait ....