Download the PHP package mikhailovlab/php-fluent-console without Composer
On this page you can find all versions of the php package mikhailovlab/php-fluent-console. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mikhailovlab/php-fluent-console
More information about mikhailovlab/php-fluent-console
Files in mikhailovlab/php-fluent-console
Package php-fluent-console
Short Description Wrapper library for working with the command line using the query builder.
License MIT
Informations about the package php-fluent-console
PhpFluentConsole
PhpFluentConsole is a command line library for working with a fluent interface. It provides flexible capabilities for creating and executing command processes, as well as support for various encodings, such as CP866, CP1251, UTF-8 and others, which is especially useful when working with Cyrillic in Windows. The library also includes a system for filtering arguments, as well as capabilities for flexible output parsing using regular expressions.
PhpFluentConsole — это библиотека для работы с командной строкой через текучий интерфейс. Она предоставляет гибкие возможности для создания и выполнения командных процессов, а также поддержку различных кодировок, таких как CP866, CP1251, UTF-8 и другие, что особенно полезно при работе с кириллицей в Windows. Библиотека также включает систему фильтрации аргументов, а также возможности для гибкого парсинга вывода с использованием регулярных выражений.
Features
-
Flexible command construction: The library allows you to dynamically generate commands via a fluent interface, which makes it easily extensible and suitable for creating other libraries or services on top of it.
-
Regular expressions for output: You can filter command output using regular expressions to search for specific strings or to identify errors in the output.
-
Encoding support: The library supports various output encodings, including Windows encodings such as CP866 and CP1251, which is useful for handling Cyrillic in the command line correctly.
-
Flexible error handling: You can customize the error output to suit your requirements - either output the command return code or search for errors using regular expressions.
- Security: Carefully check the input data, as uncontrolled input can lead to security issues, such as command injection.
Особенности
-
Гибкое построение команд: Библиотека позволяет динамически генерировать команды через текучий интерфейс, что делает ее легко расширяемой и подходящей для создания других библиотек или сервисов поверх нее.
-
Регулярные выражения для вывода: Вы можете фильтровать вывод команд с использованием регулярных выражений для поиска конкретных строк или для определения ошибок в выводе.
-
Поддержка кодировок: Библиотека поддерживает различные кодировки вывода, включая кодировки для Windows, такие как CP866 и CP1251, что полезно для корректной работы с кириллицей в командной строке.
-
Гибкая обработка ошибок: Вы можете настроить вывод ошибок, чтобы он соответствовал вашим требованиям — либо выводить код возврата команды, либо искать ошибки с помощью регулярных выражений.
- Безопасность: Внимательно проверяйте входные данные, так как неконтролируемый ввод может привести к проблемам безопасности, например, к инъекциям команд.
Installation
Установка
Method descriptions
Описание методов
- Sets the command to execute.
-
Устанавливает команду для выполнения.
- Adds an argument or part of a command.
-
Добавляет аргумент или часть команды.
- Sets the encoding for output. For example, '866' to display Cyrillic in Windows.
-
Устанавливает кодировку для вывода. Например, '866' для отображения кириллицы в Windows.
- Sets a flag that the encoding should be converted back. The method is useful for returning the output in the original encoding for working with cmd.
-
Устанавливает флаг, что нужно выполнить обратную конвертацию кодировки. Метод полезен для возврата вывода в исходной кодировке для работы с cmd.
- Returns the current command.
-
Возвращает текущую команду.
- Executes the command and returns true if the return code is 0.
-
Выполняет команду и возвращает true, если код возврата равен 0.
- Get the output after executing the command.
-
Получить вывод после выполнения команды.
- Get the return code of the command execution.
-
Получить код возврата выполнения команды.
- Checks output for errors using a regular expression.
-
Проверяет вывод на наличие ошибки по регулярному выражению.
- Gets all output lines that match a regular expression.
- Получает все строки вывода, совпавшие с регулярным выражением.
Example 1
- Getting an IP address in the Windows operating system
- Получаем ip адерс в операционной системе windows
Example 2
- List digital signature containers (CSP)
- Список контейнеров с электронными подписями
Example 3
- We can inherit from the main class and instead of specifying methods via addKey we can call them dynamically using the magic method __call
-
Мы можем наследоваться от главного класса и вместо указания методов через addKey вызывать их динамически используя магический метод __call
- This approach allows us to create flexible bindings and libraries without having to study the documentation.
- Такой подход позволяет нам создавать гибкие обвязки и библиотеки, не отвлекаясь на изучение документации.