php-etl / sylius-plugin
Adapters for the Sylius API client
Installs: 3 262
Dependents: 0
Suggesters: 1
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 2
Type:gyroscops-plugin
Requires
- php: ^8.2
- ext-json: *
- nikic/php-parser: ^4.10
- php-etl/configurator-contracts: 0.8.*
- php-etl/fast-map-plugin: *
- php-etl/packaging-contracts: 0.3.*
- php-etl/satellite-toolbox: *
- symfony/config: ^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- infection/infection: ^0.26.18
- laminas/laminas-diactoros: ^2.6
- php-etl/bucket: *
- php-etl/bucket-contracts: 0.2.*
- php-etl/phpunit-extension: *
- php-etl/sylius-api-php-client: ^2.1@dev
- php-http/mock-client: ^1.4@dev
- phpunit/php-invoker: *
- phpunit/phpunit: ^10.0
- rector/rector: ^0.15
- symfony/http-client: ^6.2
- symfony/yaml: ^6.0
This package is auto-updated.
Last update: 2024-11-08 16:07:44 UTC
README
Goal
This package aims at integration the Sylius PHP clients into the Pipeline stack. This integration is compatible with both Sylius client
Principles
The tools in this library will produce executable PHP sources, using an intermediate Abstract Syntax Tree from nikic/php-parser. This intermediate format helps you combine the code produced by this library with other packages from Middleware.
Configuration format
Building an extractor
sylius: extractor: type: productModel method: all search: - { field: enabled, operator: '=', value: true } - { field: completeness, operator: '>', value: 70, scope: ecommerce } - { field: completeness, operator: '<', value: 85, scope: ecommerce } - { field: categories, operator: IN, value: winter_collection } - { field: family, operator: IN, value: [camcorders, digital_cameras] } logger: type: 'stderr' client: api_url: 'https://demo.akeneo.com' client_id: '2_5a3jtcvwi8w0cwk88w04ogkcks00o4wowwgc8gg4w0cow4wsc8' secret: '4ww9l30ij2m8wsw8w04sgw4wgkwc8gss0sgc8cc0o0goo4wkso' username: 'demo_9573' password: 516f3e3e5
Building a loader
sylius: loader: type: productModel method: upsert logger: type: 'stderr' client: api_url: 'https://demo.akeneo.com' client_id: '2_5a3jtcvwi8w0cwk88w04ogkcks00o4wowwgc8gg4w0cow4wsc8' secret: '4ww9l30ij2m8wsw8w04sgw4wgkwc8gss0sgc8cc0o0goo4wkso' username: 'demo_9573' password: 516f3e3e5
Usage
This library will build for you either an extractor or a loader, compatible with the Sylius API.
You can use the following PHP script to test and print the result of your configuration.
<?php require __DIR__ . '/../vendor/autoload.php'; use Kiboko\Plugin\Sylius; use PhpParser\Node; use PhpParser\PrettyPrinter; use Symfony\Component\Console; use Symfony\Component\Yaml; $input = new Console\Input\ArgvInput($argv); $output = new Console\Output\ConsoleOutput(); class DefaultCommand extends Console\Command\Command { protected static $defaultName = 'test'; protected function configure() { $this->addArgument('file', Console\Input\InputArgument::REQUIRED); } protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) { $factory = new Sylius\Service(); $style = new Console\Style\SymfonyStyle( $input, $output, ); $config = Yaml\Yaml::parse(input: file_get_contents($input->getArgument('file'))); $style->section('Validation'); $style->writeln($factory->validate($config) ? '<info>ok</info>' : '<error>failed</error>'); $style->section('Normalized Config'); $style->writeln(\json_encode($config = $factory->normalize($config), JSON_PRETTY_PRINT)); $style->section('Generated code'); $style->writeln((new PrettyPrinter\Standard())->prettyPrintFile([ new Node\Stmt\Return_($factory->compile($config)->getBuilder()->getNode()), ])); return 0; } } (new Console\Application()) ->add(new DefaultCommand()) ->run($input, $output) ;