Download the PHP package thamtech/yii2-yaml without Composer

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

Yii2 Yaml

Yii2 Yaml provides a Yaml helper and a Yaml parser/dumper extension.

The Yaml helper provdesencode(), decode() and errorSummary() similar to yii\helpers\Json.

Yii2 Yaml also includes an extension of the symfony/yaml library that supports custom yaml tags representing UnsetArrayValue and ReplaceArrayValue, as well as allowing you to attach events to handle any other custom yaml tags.

For license information check the LICENSE-file.

Installation

The preferred way to install this extension is through composer.

or add

to the require section of your composer.json file.

Background

The goal of this Yii2 Yaml extension is to support Yaml in Yii2 the way support for JSON is built-in. A Yaml helper is introduced to match the API of Yii2's built-in Json helper.

Furthermore, we have extended the symfony/yaml library to support decoding and encoding of ReplaceArrayValue and UnsetArrayValue objects for use with Yii's ArrayHelper::merge() method. You can use Yii2 event handlers to process custom tags as they are parsed/decoded and pre-process objects before they are dumped/encoded.

Yii2 uses encode/decode terminology in the Json helper, while symfony/yaml uses dump/parse terminology. Our helper is consistent with the Json helper in using the encode/decode terminology.

Usage

Decoding/Parsing

Example Yaml:

Example decoding using the Yaml helper:

In the example above, you can see that the keys tagged with !yii/helpers/ReplaceArrayValue and !yii/helpers/UnsetArrayValue were automatically replaced with the helper objects ready for use with the ArrayHelper::merge() method.

In order to add your own handlers for tags like the !lookupIdFromEmployeeNumber tag, you can specify them in a thamtech\yaml\Parser configuration array that you pass to the Yaml::decode() method:

Encoding/Dumping

Example data to encode:

Dumping with the standard symfony/yaml library:

Dumping with our default Yaml helper:

In the example above, you can see that the keys tagged with !yii/helpers/ReplaceArrayValue and !yii/helpers/UnsetArrayValue were automatically encoded from the ReplaceArrayValue and UnsetArrayValue objects.

In order to add your own handlers for values like the EmployeeWithoutId object, you can specify them in a thamtech\yaml\Dumper configuration array that you pass to the Yaml::decode() method:

Configuring Default Handlers

You may not want to have to send a configuration array with one or more custom handlers every time you call Yaml::encode() or Yaml::decode(). The Yaml component sets its default Parser and Dumper definitions into Yii::$container. You can set your own default Parser and Dumper definitions there with your own handlers.

To not use any handlers by default (not even the Yaml component's default handlers):

However, it is probably more likely that you will want to start with the Yaml component's default handlers and override them or add your own. The Yaml::getDumperDefinition() and Yaml::getParserDefinition() methods are a convenient way to get Parser and Dumper definitions ready for setting in the Yii::$container.

Yaml Response Formatter

You can add the YamlResponseFormatter as a yaml formatter in your yii\web\Response component to add support for returning yaml responses.

See Also


All versions of yii2-yaml with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.5
yiisoft/yii2 Version >=2.0.14 <2.1
symfony/yaml Version >=3.4 <=3.4.29 || ^4.4.0 || ^5.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 thamtech/yii2-yaml contains the following files

Loading the files please wait ....