Download the PHP package thecodingmachine/yaml-definition-loader without Composer

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

Scrutinizer Code Quality Build Status Coverage Status

YAML Definition Loader for definition-interop

This package contains a loader that can convert YAML files to container definitions compatible with the definition-interop standard.

In order to keep things simple for newcomers, the supported YAML file is a subset of Symfony services YML file format.

Installation

You can install this package through Composer:

The packages adheres to the SemVer specification, and there will be full backward compatibility between minor versions.

Automatic discovery

If you want YAML files of your package to be automatically discoverable (using Puli), you should bind your YAML files to the "definition-interop/yaml-definition-files" binding type.

Lets assume that your service file is in "services/my_service.yml".

In your package, simply type:

Binded YML files can be discovered automatically if consumers use Puli for Discovery.

Usage

This package contains a YamlDefinitionLoader class. The goal of this class is to take a YAML file and generate a number of "entry definitions" (as defined in definition-interop).

These definitions can then be turned into a dependency injection container using the appropriate tools (like Yaco).

Note: the YamlDefinitionLoader implements the Interop\Container\Definition\DefinitionProviderInterface.

File format

Declare parameters

Declare an instance

This will declare a "my_service" service, from class My\ClassName, passing to the constructor the strings "foo" and "bar".

Reference an instance

The my_reference service will be passed in parameter to the constructor of the my_service service. To reference a service, use the @ prefix. If you want a string starting with a @, you should double it. For instance:

Call a method of a service

You can call methods of a service after generating it. For instance, you could call setters. You need to create a calls attribute and pass it a list of methods to be called. The first item is the method name and the second item is a list of parameters to pass to that method.

Set a public property of a service

Use the properties key to set a public property in a service.

Aliases

You can build services alias using the alias attribute.

Alternatively, you can also use this syntax:

Factories

You can use factory methods of other services or classes to build your services.

Static factories

The my_service instance will be returned from a call to My\ClassName::myMethod. You can even pass parameters to this method using the arguments attribute:

You can also use this alternative syntax:

Service based factories

The my_service instance will be returned from a call to myMethod on the service named factory. Notice how we used a single ':' instead of a double '::'.

You can also use this alternative syntax:

Noticeable differences with Symfony YAML services format


All versions of yaml-definition-loader with dependencies

PHP Build Version
Package Version
Requires container-interop/definition-interop Version ~0.1.0
container-interop/definition-discovery Version dev-master
symfony/yaml Version ~2.0 | ~3.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 thecodingmachine/yaml-definition-loader contains the following files

Loading the files please wait ....