Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify PHP version support #965

Closed
totten opened this issue Aug 21, 2020 · 1 comment
Closed

Clarify PHP version support #965

totten opened this issue Aug 21, 2020 · 1 comment

Comments

@totten
Copy link

totten commented Aug 21, 2020

The disposition of PHP version support is a bit confusing. I was expecting it to work on 7.1.3+ b/c composer.json pointed to that version.

Below are a couple different procedures to see the confusion.

Steps to reproduce (A)

  • Open a shell with PHP 7.1.33.
  • Download the current robo.phar (2.1.0).
  • Run robo --help

Expected behavior (A)

Show help screen

Actual behavior (A)

$ ./robo.phar --help
PHP Fatal error:  Uncaught Error: Call to undefined function Symfony\Component\Console\Output\stream_isatty() in  phar:///home/myuser/bin/robo/vendor/symfony/console/Output/StreamOutput.php:113
Stack trace:
#0 phar:///home/myuser/bin/robo/vendor/symfony/console/Output/StreamOutput.php(51): Symfony\Component\Console\Output\StreamOutput->hasColorSupport()
#1 phar:///home/myuser/bin/robo/vendor/symfony/console/Output/ConsoleOutput.php(42): Symfony\Component\Console\Output\StreamOutput->__construct(Resource id #45, 32, NULL, NULL)
#2 phar:///home/myuser/bin/robo/src/Runner.php(107): Symfony\Component\Console\Output\ConsoleOutput->__construct()
#3 phar:///home/myuser/bin/robo/src/Runner.php(264): Robo\Runner->loadRoboFile(NULL)
#4 phar:///home/myuser/bin/robo/src/Runner.php(155): Robo\Runner->getRoboFileCommands(NULL)
#5 /home/myuser/bin/robo(50): Robo\Runner->execute(Array)
#6 {main}
  thrown in phar:///home/myuser/bin/robo/vendor/symfony/console/Output/StreamOutput.php on line 113

Upon inspection, the PHAR file is missing the stream_isatty() polyfill from symfony/polyfill-php72.

Steps to reproduce (B)

  • Open a shell with PHP 7.1.33.
  • Clone https://github.com/consolidation/Robo/
  • Run composer install
  • Run ./robo --help

Expected behavior (B)

Show help screen

Actual behavior (B)

[bknix-min:/tmp/Robo] ./robo --help

PHP Fatal error:  Declaration of Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch(Symfony\Contracts\EventDispatcher\object $event, ?string $eventName = NULL): Symfony\Contracts\EventDispatcher\object must be compatible with Psr\EventDispatcher\EventDispatcherInterface::dispatch(Psr\EventDispatcher\object $event) in /tmp/Robo/vendor/symfony/event-dispatcher-contracts/EventDispatcherInterface.php on line 19
PHP Stack trace:
PHP   1. {main}() /tmp/Robo/robo:0
PHP   2. Robo\Runner->execute() /tmp/Robo/robo:48
PHP   3. Robo\Runner->run() /tmp/Robo/src/Runner.php:156
PHP   4. Robo\Robo::createDefaultContainer() /tmp/Robo/src/Runner.php:214
PHP   5. Robo\Robo::configureContainer() /tmp/Robo/src/Robo.php:161
PHP   6. League\Container\Container->share() /tmp/Robo/src/Robo.php:242
PHP   7. League\Container\Container->add() /tmp/Robo/vendor/league/container/src/Container.php:163
PHP   8. League\Container\Definition\DefinitionFactory->getDefinition() /tmp/Robo/vendor/league/container/src/Container.php:142
PHP   9. class_exists() /tmp/Robo/vendor/league/container/src/Definition/DefinitionFactory.php:20
PHP  10. spl_autoload_call() /tmp/Robo/vendor/league/container/src/Definition/DefinitionFactory.php:20
PHP  11. Composer\Autoload\ClassLoader->loadClass() /tmp/Robo/vendor/league/container/src/Definition/DefinitionFactory.php:20
PHP  12. Composer\Autoload\includeFile() /tmp/Robo/vendor/composer/ClassLoader.php:322
PHP  13. include() /tmp/Robo/vendor/composer/ClassLoader.php:444
PHP  14. spl_autoload_call() /tmp/Robo/vendor/symfony/event-dispatcher/EventDispatcher.php:32
PHP  15. Composer\Autoload\ClassLoader->loadClass() /tmp/Robo/vendor/symfony/event-dispatcher/EventDispatcher.php:32
PHP  16. Composer\Autoload\includeFile() /tmp/Robo/vendor/composer/ClassLoader.php:322
PHP  17. include() /tmp/Robo/vendor/composer/ClassLoader.php:444
PHP  18. spl_autoload_call() /tmp/Robo/vendor/symfony/event-dispatcher/EventDispatcherInterface.php:23
PHP  19. Composer\Autoload\ClassLoader->loadClass() /tmp/Robo/vendor/symfony/event-dispatcher/EventDispatcherInterface.php:23
PHP  20. Composer\Autoload\includeFile() /tmp/Robo/vendor/composer/ClassLoader.php:322
PHP  21. include() /tmp/Robo/vendor/composer/ClassLoader.php:444

Upon inspection, composer.json actually has two slightly contradictory statements:

  • require: php is >=7.1.3
  • config: platform: php is 7.2.28.

It could make sense if the intent is to offer different levels of support for different scenarios, eg

  • Downstream consumers who use robo as a library - for which the minimum is 7.1.
  • Downstream consumers who use robo as an application/PHAR - for which the minimum is 7.2.

Note: I locally edited the config: platform: php to pin to 7.1.3 and cleared composer.lock / vendor. Given appropriate dependencies, ./robo --help was fine.

System Configuration

Suggestions

  • If the intent is to consistently support PHP 7.1+, then change config: platform: php to 7.1.
  • If the intent is to consistently support PHP 7.2+, then change require: php to 7.2.
  • If the intent is to some kind of mixed-support situation, then keep composer.json -- but update the application's entrypoint (./robo?) to check the version and give an error message to explain the mixed-support.
@greg-1-anderson
Copy link
Member

I clarified the PHP version support intentions in the README. The platform.php setting is 7.2 because that is the PHP version required by Symfony 5. Symfony 4 and PHP 7.1 are also supported when using Robo as a library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants