ptlis / shell-command Goto Github PK
View Code? Open in Web Editor NEWA better abstraction for running processes from PHP
License: MIT License
A better abstraction for running processes from PHP
License: MIT License
Composer raises deprecation errors when installing the package. The main concern is that it states that some classes will no longer be autoloader when composer v2.0 hits.
Not critical, however, as they only look like test classes.
Deprecation Notice: Class ptlis\ShellCommand\Test\Mocks\MockProcessTest located in ./vendor/ptlis/shell-command/tests/Unit/Mocks/MockProcessTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.8/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201 Deprecation Notice: Class ptlis\ShellCommand\Test\Mocks\MockCommandTest located in ./vendor/ptlis/shell-command/tests/Unit/Mocks/MockCommandTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.8/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201 Deprecation Notice: Class ptlis\ShellCommand\Test\Mocks\MockCommandBuilderTest located in ./vendor/ptlis/shell-command/tests/Unit/Mocks/MockCommandBuilderTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.8/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201 Deprecation Notice: Class ptlis\ShellCommand\Test\ProcessOutputTest located in ./vendor/ptlis/shell-command/tests/Unit/ProcessOutputTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.8/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
This is purely to make debugging a little easier when built commands return non-zero status codes.
Value set using setCwd()
is not used in validateCommand()
, so validation fails if relative command is not run in the same working directory.
How to test:
<?php
require __DIR__ . '/vendor/autoload.php';
$builder = (new \ptlis\ShellCommand\CommandBuilder())
->setCwd('/')
->setCommand('./bin/ls');
echo $builder->buildCommand();
This will succeed if called in /
, but fail if script is called from any other directory:
PHP Fatal error: Uncaught RuntimeException: Invalid command "./bin/ls" provided to ptlis\ShellCommand\CommandBuilder. in /app/vendor/ptlis/shell-command/src/CommandBuilder.php:180
Bug is in line 179 of CommandBuilder->buildCommand()
:
shell-command/src/CommandBuilder.php
Lines 177 to 181 in 5835e2d
Hand-made patch:
- if (!$this->environment->validateCommand($this->command) {
+ if (!$this->environment->validateCommand($this->command, $this->cwd)) {
Class ptlis\ShellCommand\Test\Mocks\MockCommandBuilderTest located in vendor/ptlis/shell-command/tests\Unit\Mocks\MockCommandBuilderTest.php does not comply with psr-4 autoloading standard. Skipping.
localhost > MAMP > PHP 8.1.0 + Composer 2.2.3
Thanks for the package ๐
I have a feature idea: It would be nice to have an option to change the working directory of a command.
This way an app could stay in the current working directory, but execute a binary from within another directory. This is often useful when running multiple tools which require different (relative oder absolute) entry points themself.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.