pug-php / pug

Pug template engine for PHP
https://www.phug-lang.com
MIT License
387 stars 42 forks source link

PHP 8 support? #245

Closed windware-ono closed 3 years ago

windware-ono commented 3 years ago

I get Undefined constant "STDOUT" error using this on PHP 8.0 under vendor/phug/phug/src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php in Phug\Renderer::hasColorSupport for @posix_isatty(STDOUT);.

kylekatarnls commented 3 years ago

I run pug-php with PHP 8 for months with no issues. hasColorSupport() tries to check if your system supports color in CLI.

The case where STDOUT is not defined is pretty rare and not related to the version but more likely the config (in a normal install of PHP, it's fopen('php://stdout', 'w')) but I can see in the last version of Symfony, the presence of STDOUT is also checked first. I could follow this path and just disable color if the constant is missing.

windware-ono commented 3 years ago

Hmm, the PHP I installed is PHP 8.0.3 on Ubuntu 20.04 through ppa:ondrej/php, so I thought I'm not in a rare environment.

It does say STDOUT/IN/ERR are only defined in CLI SAPI but then it still worked with PHP 7.4 from the same ppa repo enabling same PHP modules. https://www.php.net/manual/en/features.commandline.io-streams.php

Thanks for the fix.

kylekatarnls commented 3 years ago

Fixed in phug 1.8.2, please upgrade and retry.