Closed alessandro-fazzi closed 3 years ago
Hello,
Phug
without namespace is also available:
https://github.com/phug-php/phug/blob/master/src/Phug/Phug/Phug.php
But still we could 'Phug\Phug'
instead of using the alias.
You're the first to report such trouble. So there is likely something preventing the alias Phug
to properly autoload Phug\Phug
or maybe it's something new in composer.
Hello, I tried with composer 1 and 2 and PHP 7.4 and 8. Can you provide installation steps from scratch, PHP, composer and phug version so I can try to reproduce it. I will re-open then. Thanks.
@kylekatarnls
PHP 7.2.34 Composer version 2.0.13
{
"require": {
"pug-php/pug": "^3.0",
"mobiledetect/mobiledetectlib": "^2.8",
"symfony/validator": "^5.0"
},
"config": {
"classmap-authoritative": true
}
}
composer show 262ms
js-phpize/js-phpize 2.8.4 Convert js-like syntax to standalone PHP code.
js-phpize/js-phpize-phug 2.2.1 Convert js-like syntax to standalone PHP code in Phug template.
js-transformer/js-transformer 1.0.0
mobiledetect/mobiledetectlib 2.8.37 Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific ...
nodejs-php-fallback/nodejs-php-fallback 1.5.2 Allow you to call node.js module or scripts throught PHP and call a fallback function if node.js is not available
phug/js-transformer-filter 1.2.0 Allow to use any js-transformer as filter in Phug
phug/phug 1.8.2 Pug (ex-Jade) facade engine for PHP, HTML template engine structured by indentation
pug-php/pug 3.4.1 HAML-like template engine for PHP
symfony/deprecation-contracts v2.4.0 A generic function and convention to trigger deprecation notices
symfony/polyfill-ctype v1.22.1 Symfony polyfill for ctype functions
symfony/polyfill-mbstring v1.22.1 Symfony polyfill for the Mbstring extension
symfony/polyfill-php73 v1.22.1 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80 v1.22.1 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/translation-contracts v2.4.0 Generic abstractions related to translation
symfony/validator v5.2.7 Provides tools to validate values
symfony/var-dumper v5.2.7 Provides mechanisms for walking through any arbitrary PHP variable
require_once Wordless::join_paths(dirname(__FILE__), '../vendor/autoload.php');
// somewhere else
$pug = new \Pug(WordlessPugOptions::get_options());
$pug->displayFile($template_path, $locals);
and it throws
Fatal error: Uncaught Error: Class 'Pug' not found in [...]/wp-content/plugins/wordless/wordless/helpers/render_helper.php
while using \Pug\Pug
works. I know this is Pug
and not Phug
but following the documentation we should have a root level Pug
too. Since the problem sounded related, I'm reporting this case too.
Speaking about the cli ./vendor/bin/phug compile
throws
class 'Phug' not found in [...]/wp-content/plugins/wordless/vendor/phug/phug/src/Phug/Phug/Phug/Cli.php on line 182
as per original posting.
Anyway: I've reported this for the sake of completeness, but if it's a problem on my own env I'd don't ask for your time more than this :)
I think there is something different in the wordpress autoload aggregation.
But then I think I can reproduce and CLI support for WordPress worth to take a look. :)
@kylekatarnls I'm not sturdy enough on the matter, but it seems to me that the classmap-authoritative
could be my "problem".
If you're going to ask why I've enabled the authoritative classmap method: optimization. As studied in https://getcomposer.org/doc/articles/autoloader-optimization.md (considering I've studied it the right way :P)
Would be someway feasible to use the autoload.files
feature in "your" composer.json
in order to require the file with the class_alias
? Or am I misusing the classmap-authoritative
?
Whatever: thanks for your time and support.
Hello, I installed a new wordless app from scratch and was able to reproduce it.
However it works fine ./vendor/bin/pug
works fine. Is there a particular reason for using phug
over pug
in your case? If not you can go safely using pug
.
That's true. Actually it's a solution for me since I'm switching to pug
in order to have the :php
filter preloaded.
By the way configuring mine composer.json
with
{
"require": {
"pug-php/pug": "^3.0",
"mobiledetect/mobiledetectlib": "^2.8",
"symfony/validator": "^5.0"
},
"config": {
"classmap-authoritative": true
},
"autoload": {
"files": [ "vendor/phug/phug/src/Phug/Phug/Phug.php" ]
}
}
Was solving the issue.
Looking at "my own business" we could consider this solved, but there's still the scenario where someone else could use classmap-authoritative
and could be bound to phug
.
Thanks for the check, thanks for the tip and thanks for the time :)
This is also fixed in dev-master
: https://github.com/phug-php/phug/pull/82 so next release will have it.
Hello,
I encountered an issue with the following code:
I expected to get: a compiled file and a
0
exit codeBut I actually get:
1
exit code with the errorI can't get if in https://github.com/phug-php/phug/blob/f4e169a92711f6bc33fbdb4ce64d63b159a017c6/phug#L22 we should have
or if in https://github.com/phug-php/phug/blob/f4e169a92711f6bc33fbdb4ce64d63b159a017c6/src/Phug/Phug/Phug/Cli.php#L40 we should have
or if it's just a problem with my setup.
Thanks!