cleverage/process-bundle
CleverAge ProcessBundle is a Symfony bundle for configuring series of tasks to run in order, making import and export workflows much easier to set up while supporting far more custom process needs. Compatible with stable Symfony and LTS releases, with a demo project available.
ArrayElementTransformer (array_element) and ArrayLastTransformer (array_last) return null when the position is outside the array (or the array is empty), without the "Undefined array key" PHP warning (it was an exception in debug mode, null in production); a negative index before the start of the array no longer returns its first element. InputCsvReaderTask (input_csv_reader): an input that is not a path (e.g. null) throws an explicit UnexpectedValueException instead of an "Undefined array key" PHP warning followed by a TypeError. Documentation: rate n/a of advanced_stat_counter, headers: [] of csv_reader / input_csv_reader, optional $accessor of ConditionTrait, ParsedExpression accepted by the condition of rules. Add tests.StopTask (stop): a process stopped on purpose is identified as stopped, not as failed. Its history is flagged as stopped (new ProcessHistory::STATE_STOPPED, setStopped(), isStopped()) instead of failed, the Process <code> stopped log is written at the success_level (instead of Process <code> failed at the failed_level), and the cleverage_process.end event tells it with the new ProcessEvent::isProcessStopped(). The process still ends normally (tasks finalized, exit code 0, parent process going on). Update documentation, add tests.InvalidArgumentException naming the service, the tasks and the process): all these tasks ran with the same instance, initialized with the options of each task in turn, without error. Declare the task services with shared: false (applied by the autoconfiguration of TaskInterface since 5.4). Update documentation, add tests.ProcessManager and ProcessHelpCommand are typed on TaskRegistryInterface instead of the final TaskRegistry class: the task registry can be decorated or replaced. Add tests.file_splitter, log_empty_lines of the CSV readers, empty lines of the line readers, invalid regular expressions of the conditions, cache pool of the cached transformer, missing serializer / validator, exceptions of the bundle in the reference pages, failure of a sub-process of process_executor, sleep_on_finalize_interval of process_launcher, initialization failures, process_options of process_launcher in UPGRADE.md.FileSplitterTask (file_splitter), CsvSplitterTask (csv_splitter) and of the JSON buffer of ProcessLauncherTask (json_buffering) are created with a random name, exclusively (an existing path, symbolic links included, is never reused) and readable by their owner only, instead of a name derived from the time (uniqid()), opened in w mode with the permissions of the umask. Update documentation, add tests.ProcessManager: the iterable tasks that produced items and the blocking tasks waiting for proceed() are tracked by task configuration instead of task code, and forgotten when their process ends. A task of a sub-process (process_executor) with the same code as a task of the parent no longer makes the parent lose the output of its blocking task (without error) or skip the flush at the end of its iteration (merged batches), and a failed sub-process no longer leaves its tasks to its next execution. Add tests.ProcessManager: restore the previous task configuration (getTaskConfiguration(), read by the log processors for task_code and task_service) when a task, an initialization, a finalization or a sub-process ends. The logs of an iterable task no longer lose their task after its first item, and the logs of a parent process are no longer attributed to a task of its sub-process; the failing task is kept for the logs of the process failure. Add tests.LineReaderTask (line_reader) and InputLineReaderTask (input_line_reader): the last line of a file that does not end with a line break is no longer lost. Add tests.YamlWriterTask (yaml_writer): a write failure throws a RuntimeException instead of a PHP warning (an exception in debug mode only: in production, the path was output as if the file had been written), and the parent directory is created if needed, as for the other writers. Update documentation, add tests.cleverage:process:execute: the process codes and the output format are checked before any process is executed (explicit message for dump without symfony/var-dumper); the output is printed to STDOUT whatever the verbosity when --output-format is given (it required -vv); a non-array output that cannot be stored as JSON stream is reported on the error output instead of being silently lost. Update documentation, add tests.ProcessConfigurationRegistry::reset(), tagged kernel.reset: a long-running worker (Messenger, UI bundle) releases the resolved process configurations, with the task instances and states (inputs, outputs, aggregated data) of their last execution, between two messages. Add tests.ProcessStopCheckerInterface (autoconfigured, tag cleverage_process.stop_checker, new optional $stopCheckers argument of ProcessManager) are asked before each task execution; when one of them returns true, the task is not executed and the process fails with a ProcessFailedException whose previous exception is the new ProcessStoppedException. Add documentation and tests.tests.old directory.ignoreErrors and [@phpstan-ignore](https://github.com/phpstan-ignore) comments (report unmatched ignored errors again), add missing iterable value types and generic types in PHPDoc, remove unreachable code in AbstractIterableOutputTask and InputAggregatorTask.AbstractConfigurableTask::getOptions(): ?array, will be fixed in v6.0). Default to a ContextualOptionResolver in ProcessState and to a property accessor in ConditionTrait when none is set.transformers option (TransformerTask, MappingTransformer, ArrayMapTransformer, CachedTransformer, RulesTransformer, generic transformers) also accepts a list, whose items are a transformer code without options (- trim) or a single code: options map (- callback: {...}), to chain the same transformer without # suffix. The map syntax is still supported. Update documentation, add tests.address.city) on an array destination, which silently created an address.city literal key, is deprecated and will throw an \UnexpectedValueException in v6.0. Use [address.city] for a literal key or [address][city] for a nested array; a simple property name (e.g. name) is still added as a key. Update documentation, add tests.\XMLReader (constant memory), outputting each element named node_name as a \DOMElement in its own \DOMDocument, ready for XpathEvaluatorTransformer. The file path is set in the file_path option or given as input. Add documentation and tests.mode option (default wb, e.g. ab to append to an existing JSON Lines file), and release the file on finalize(). Update documentation, add tests.logs option, globally (clever_age_process.logs) or per process (configurations.<code>.logs): success_level (default info) for Process <code> succeed, and failed_level (default debug) for the new Process <code> failed log, written when a process fails, with or without exception. Update documentation, add tests.\IteratorAggregate input whose getIterator() does not return an \Iterator (e.g. another \IteratorAggregate) is iterated instead of failing with a TypeError. Update documentation, add tests.TypeError or an Error: CsvResource rejects a blank header line and checks ftell(), XpathEvaluatorTransformer throws an explicit \UnexpectedValueException on an invalid query (with the libxml messages), a namespace node to unwrap or a node without document, SlugifyTransformer on a value that cannot be transliterated, ProcessState::getContext() returns [] until the context is defined, GenericTransformer and TransformerTrait throw a \LogicException when not initialized, IterableBatchTask and JsonStreamReaderTask can be flushed / iterated before their first execution, RegistryCompilerPass checks its configuration, SubprocessInstance checks the PHP executable. Update documentation, add tests.\Throwable, so that the TypeError of the property accessor on a scalar input is set on the state (with the property error context) and handled according to the task error_strategy instead of escaping it. Update documentation, add tests.\UnexpectedValueException instead of a TypeError when headers is null, and the CSV tasks release their file on finalize() so that the task can be executed again. Update documentation, add tests.autoincrement, the suffix was computed on the whole path (a dot in a directory name was taken as the extension, making the move fail for a file without extension) and an existing numeric suffix of the file name was replaced (report-2024.csv became report-1.csv). The suffix is now appended to the file name only (report-2024-1.csv, file-1, .env-1). Update documentation, add tests.\stdClass item without the property was replaced by a copy in the output, so the input object was not modified; the property is now added to the item itself. Update documentation, add tests.null) throws an explicit \UnexpectedValueException (No file path given as input) instead of a PHP warning followed by a TypeError. Update documentation, add tests.\stdClass destination (initial_value or keep_input) threw Property '...' is not writable, it is now added when the target is a simple property name (nested paths still throw). Update documentation, add tests.split_character of CsvWriterTask and SplitJoinLineTask must be a string (a wrong type used to fail later with a TypeError), write_headers of CsvWriterTask and log_empty_lines of CsvReaderTask are cast to bool (any value used to be evaluated as a boolean, so it is still accepted). Update documentation, add tests.withComposerBased() sets (removed SYMFONY_64 / PHPUNIT_100 sets), declare used Symfony packages and PHPUnit range in composer.json, apply quality tools fixesnull, and AdvancedStatCounterTask was skipped when not logging), so they can be placed anywhere in a branch. Update documentation, add tests.#suffix is accepted on transformer codes (callback#1, callback#reverse), and anchor the matching regex (an empty suffix is no longer accepted). Update documentation, add tests.options option to Process::setOptions(), support string commandline through Process::fromShellCommandline(), validate option types. Update documentation, add tests.process_options normalizer returned an array despite its scalar return type, so the task always failed with a TypeError. Update documentation, add tests.event_name option (regression since v4.0). event_name is now optional: when null (default), the event is dispatched under its class name. Update documentation, add tests.\DateTimeImmutable input is converted to a \DateTime instead of throwing a TypeError. Update documentation, add tests.replacement is no longer cast to the string "Array", and requires an array pattern. Update documentation, add tests.required: false and no default can now be used; its placeholders are replaced by null when omitted. Update documentation, add tests.\UnexpectedValueException on an empty file or invalid XML (with the libxml error messages) instead of a ValueError or a silent empty \DOMDocument. Update documentation, add tests.ProcessState::addErrorContextValue(): accept any value type, so that iterable tasks on an empty iterable are skipped and PropertySetterTask reports the original exception instead of a TypeError. Update documentation, add tests.cached (key built after key_transformers), reject an invalid transliterator in slugify with an InvalidOptionsException, remove the unreachable error branch of type_setter. Update documentation, add tests.max_lines lines of the source. Update documentation, add tests.null batch_count (only flush at the end), allow scalar inputs in conditions ('' path on the whole value), aggregate null column values. Update documentation, add tests.\UnexpectedValueException when a line decodes to a scalar, create the missing parent directory when writing. Update documentation, add tests.Input* variants): reset the state at the end of the iteration, so that a following input is read from its beginning. Update documentation, add tests.setRequired() in ImplodeTransformer and SprintfTransformer, stray namespace in TrimTransformer, wrong or missing docblocks. Add tests.ProcessFailedException (with the original exception as previous) instead of a FatalError, so that the command exits with a non-zero code when a process fails and ProcessLauncherTask detects failed sub-processes. Update documentation, add tests.max_lines data lines (instead of max_lines - 2), no infinite loop with max_lines <= 2 (max_lines must now be an integer greater than 0), no header-only file at the end. Update documentation, add tests.flush() may be called several times. Document that flush() implementations must be idempotent. Update documentation, add tests.setAllowedTypes() on HashTransformer (raw_output), SimpleBatchTask (batch_count), ConditionTrait (empty, not_empty), NormalizerTask / SerializerTask / DeserializerTask (context) and ObjectUpdaterTask (property_path): a wrong type is now reported when the options are resolved. Add tests.TypeError: validate FileSplitterTask max_lines (greater than 0, also when given as input), catch any \Throwable in PropertySetterTask, type SlugifyTransformer options, explicit exceptions in InputFolderBrowserTask (no folder path) and XmlFile::write() (saveXML() failure). Update documentation, add tests.event_name is set, listening to CleverAge\ProcessBundle\Event\EventDispatcherTaskEvent is deprecated (the event is still dispatched under its class name, with an E_USER_DEPRECATED error, if it has listeners). Listen to the configured event_name instead: the BC layer will be removed in v6.0.initialize() is deprecated (an E_USER_DEPRECATED error is triggered). In v6.0, the process will fail before executing any task.cleverage/flysystem-process-bundle instead.CleverAge\ProcessBundle\Task\File\YamlCleverAge\ProcessBundle\Transformer\ArrayCleverAge\ProcessBundle\Transformer\SerializationCleverAge\ProcessBundle\Transformer\DateCleverAge\ProcessBundle\Transformer\StringCleverAge\ProcessBundle\Transformer\ObjectSymfony\Component\Form\Exception\InvalidConfigurationException by Symfony\Component\Config\Definition\Exception\InvalidConfigurationExceptioncleverage_process\CleverAge\ProcessBundle\Task\Debug\MemInfoDumpTask has been deleted without suggested replacementdefault_error_strategy on clever_age_process level. See Quick Start/Global configurationleague/flysystem-bundle is not required anymoresymfony/dotenv and symfony/runtimesymfony/form, symfony/messenger & symfony/schedulerUpgrade psr/cache
How can I help you explore Laravel packages today?