Download the PHP package surgiie/transformer without Composer

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

Transformer

transformer is a PHP package for transforming values or input, powered by the Laravel framework's validation components.

Tests

Installation

`

Usage

To use the package, pass your data and an array of callable functions that your data should be passed through:

Note that the syntax is similar to the Laravel validation syntax because this package is powered by the same components.

Passing Arguments

You can specify arguments for your functions using a <function>:<comma-delimited-list> syntax:

By default, the first argument passed to your function will be the value being formatted, followed by the arguments specified in the order provided. If your function does not accept the value as the first argument, you can use the :value: placeholder to specify the order. For example:

Optional Transformation

If you only want to transform a value if it is not null or "blank", you can use the ? character in the chain of functions to specify when to break out of processing. This is often placed at the start of the chain:

Note: This package uses Laravel's blank helper to determine blank/empty values. If you have more complex logic for breaking out of rules, you can use a closure or a \Surgiie\Transformer\Contracts\Transformable class and call the 2nd argument exit callback.

Closures and Transformable Classes

You can use closures to transform your values:

Alternatively, you can implement the Surgiie\Transformer\Contracts\Transformable contract and use class instances:

Array Input

You can also format nested array data using dot notation:

Wildcards

You can also use wildcards on keys to apply transformers on keys that match the wildcard pattern:

Object Values/Method Delegation

It is possible to delegate a function call to an object if the value has been converted to an instance. Using the syntax -><methodName>:args, you can specify method chaining on that instance:

You can also use class constants that accept a single value as its constructor, for example:

Guard Layer Over Execution

By default, all available functions that are callable at runtime will be executed. However, if you want to add a protection or security layer that prevents certain methods from being called, you can add a guard callback that checks if a method should be called by returning true:

Manually Transforming Values/Single Values

To format a one-off value, use the Transformer class:

Use Traits

To transform data and values on-the-fly in your classes, use the \Surgiie\Transformer\Concerns\UsesTransformer trait:

Use the Request Macro

To transform data using a macro on a Illuminate\Http\Request object instance, call the transform() method on the request, which returns the transformed data.

When calling on a FormRequest object, it uses the validated() function to retrieve the input data. Note that this requires the data you are targeting to be defined as a validation rule in your form request's rules function, otherwise the data will be omitted from transformation.

Package Discovery/Don't Discover

Laravel automatically registers the package service provider, but if you don't want this, you can ignore package discovery for the service provider by including the following in your composer.json:

Contribute

Contributions are always welcome in the following manner:


All versions of transformer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.2
illuminate/http Version ^9.0|^10.0
illuminate/support Version ^9.0|^10.0
illuminate/validation Version ^9.0|^10.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 surgiie/transformer contains the following files

Loading the files please wait ....