PHPackages                             xervice/processor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xervice/processor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xervice/processor
=================

2.0.0(7y ago)047MITPHPPHP &gt;=7.1.0

Since Apr 29Pushed 7y ago1 watchersCompare

[ Source](https://github.com/xervice/processor)[ Packagist](https://packagist.org/packages/xervice/processor)[ RSS](/packages/xervice-processor/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

Processor
=========

[](#processor)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fd80d1387bb042b6092cd8449d0ab3b99dca6e7b1e6820b69903dcb1b3aeeb15/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f786572766963652f70726f636573736f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xervice/processor/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/e573b021110980fdabf9079e57d1640cc73fdde3233a5c475339a0bfd63dbf11/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f786572766963652f70726f636573736f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xervice/processor/?branch=master)

Installation
------------

[](#installation)

```
composer require xervice/processor

```

Configuration
-------------

[](#configuration)

You must create a new process configuration plugin implementing \\Xervice\\Processor\\Business\\Dependency\\ProcessConfigurationPluginInterface. That class you have to register in the ProcessorDependencyProvider to add your process.

A process is a data livecycle with the following steps:

1. Read input
2. Validate data
3. Hydrate data
4. Translate data
5. Process data
6. Write data

All login for the given steps can be configured in the process configuration plugin.

### Read input

[](#read-input)

You can define an InputHandler in your process configuration to read the data.

```
    /**
     * @return \Xervice\Processor\Business\Model\InputHandler\InputHandlerInterface
     */
    public function getInputHandler(): InputHandlerInterface
    {
        return new RawJsonFileRowInputHandler();
    }
```

### Validate data

[](#validate-data)

For validating you can add one or more ValidatorPlugins to your process configuration to validate your data. The config syntax is based on the xervice/validator module.

```
    /**
     * @return \Xervice\Validator\Business\Dependency\ValidatorConfigurationProviderPluginInterface[]
     */
    public function getValidatorConfigurationPlugins(): array
    {
        return [
            new TestValidator()
        ];
    }
```

```
    class TestValidator implements ValidatorConfigurationProviderPluginInterface
    {
        /**
         * @return array
         */
        public function getValidatorConfiguration(): array
        {
            return [
                [
                    'test' => [
                        'required' => true,
                        'type' => IsType::TYPE_ARRAY
                    ]
                ]
            ];
        }

    }
```

### Hydrating

[](#hydrating)

After your data is validated you can hydrate the information by adding HydratePlugins to your process configuration. Syntax of the configuration is based on the xervice/array-handler module.
Giving only the fieldname in the config will remove this entry from the data.

```
    /**
     * @return \Xervice\Processor\Business\Dependency\ProcessHydratorPluginInterface[]
     */
    public function getHydratorPlugins(): array
    {
        return [
            new TestHydrator()
        ];
    }
```

```
class TestHydrator implements ProcessHydratorPluginInterface
{
    /**
     * @return array
     */
    public function getHydratorConfiguration(): array
    {
        return [
            [
                'newValues' => function (array $payload) {
                    return [
                        [
                            $payload['test'][0]
                        ],
                        [
                            $payload['test'][1]
                        ]
                    ];
                },
                'test'
            ]
        ];
    }
}
```

### Translating

[](#translating)

After hydrating the information you can translate them into your needed structure. For that you can add translate plugins to your process configuration. Syntax is also based on the xervice/array-handler module. Here you can define TranslationFunction. You can add new TranslationFunctions to the ProcessorDependencyProvider.

```
    /**
     * @return \Xervice\Processor\Business\Dependency\ProcessTranslationPluginInterface[]
     */
    public function getTranslatorPlugins(): array
    {
        return [
            new TestTranslator()
        ];
    }
```

```
class TestTranslator implements ProcessTranslationPluginInterface
{
    /**
     * @return array
     */
    public function getTranslationConfiguration(): array
    {
        return [
            [
                'TestTranslator',
                'TestTranslator' => [
                    'field' => 'transOne',
                    'source' => 'newValues'
                ],
                'transTwo' => function (array $payload) {
                    return $payload['transOne'] ?? null;
                }
            ]
        ];
    }
}
```

```
use Xervice\Processor\Business\Model\Translator\TranslatorInterface;

class TestTranslatorFunction implements TranslatorInterface
{
    /**
     * @return string
     */
    public function getName(): string
    {
        return 'TestTranslator';
    }

    /**
     * @param array $payload
     * @param array $options
     *
     * @return array
     */
    public function translate(array $payload, array $options = null): array
    {
        if (!isset($payload['isTranslated'])) {
            $payload['isTranslated'] = 0;
        }

        $payload['isTranslated']++;

        if (is_array($options)) {
            $payload[$options['field']] = $payload[$options['source']];
        }

        return $payload;
    }

}
```

```
class ProcessorDependencyProvider extends \Xervice\Processor\ProcessorDependencyProvider
{
    /**
     * @return \Xervice\Processor\Business\Dependency\ProcessConfigurationPluginInterface[]
     */
    protected function getProcessConfigurationPlugins(): array
    {
        return [
            new ProcessConfiguration()
        ];
    }

    /**
     * @return \Xervice\Processor\Business\Model\Translator\TranslatorInterface[]
     */
    protected function getTranslatorFunctions(): array
    {
        return [
            new TestTranslatorFunction()
        ];
    }
}
```

### Processing

[](#processing)

Processing the data is the jump into your module business logic. For that you've a hook method in your process configuration. The return value is data payload you want to write.

```
    /**
     * @param array $data
     *
     * @return array
     */
    public function process(array $data): array
    {
        $data['isProcessed'] = true;
        // $this->getFacade()->processYourOwnData($data);

        return $data;
    }
```

### Write data

[](#write-data)

At the end the data will be given to your OutputHandler to persist them. You can define the OutputHandler in your process configuration.

```
    /**
     * @return \Xervice\Processor\Business\Model\OutputHandler\OutputHandlerInterface
     */
    public function getOutputHandler(): OutputHandlerInterface
    {
        return new RawJsonFileOutputHandler();
    }
```

Using
-----

[](#using)

You can run a process by using the console command:

```
vendor/bin/xervice process:run -p YOUR_PROCESS_NAME

# With input and/or output info
vendor/bin/xervice process:run -p YOUR_PROCESS_NAME -i input
vendor/bin/xervice process:run -p YOUR_PROCESS_NAME -o output
vendor/bin/xervice process:run -p YOUR_PROCESS_NAME -i input -o output

```

Also you can use the ProcessorFacade to trigger a process:

```
$processConfig = (new ProcessRunDataProvider())
   ->setName('YOUR_PROCESS_PROCESS')
   ->setInput('input')
   ->setOutput('output');

$processorFacade->runProcess($processConfig);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

2571d ago

Major Versions

1.0.0 → 2.0.02019-05-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ba15174c6a847524e2118ff1b34670252159fa2bee234292381e090e3f1b3a1?d=identicon)[mibexx](/maintainers/mibexx)

---

Top Contributors

[![mibexx](https://avatars.githubusercontent.com/u/12134020?v=4)](https://github.com/mibexx "mibexx (8 commits)")

###  Code Quality

TestsCodeception

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/xervice-processor/health.svg)

```
[![Health](https://phpackages.com/badges/xervice-processor/health.svg)](https://phpackages.com/packages/xervice-processor)
```

###  Alternatives

[dragon-code/benchmark

Simple comparison of code execution speed between different options

11934.7k5](/packages/dragon-code-benchmark)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
