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

PHP on Alpine gives Warning: Use of undefined constant GLOB_BRACE #719

Closed
zrhoffman opened this issue Sep 23, 2018 · 7 comments
Closed

PHP on Alpine gives Warning: Use of undefined constant GLOB_BRACE #719

zrhoffman opened this issue Sep 23, 2018 · 7 comments
Labels

Comments

@zrhoffman
Copy link

Steps to reproduce:

docker run --rm -it php:alpine php -r 'var_dump(GLOB_BRACE);'

Expected result

int(1024)

Actual result


Warning: Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' (this will throw an Error in a future version of PHP) in Command line code on line 1
string(10) "GLOB_BRACE"

This is an Alpine-specific issue. docker run --rm -it php:stretch php -r 'var_dump(GLOB_BRACE);' produces the expected result.

@zrhoffman zrhoffman changed the title Warning: Use of undefined constant GLOB_BRACE PHP on Alpine gives Warning: Use of undefined constant GLOB_BRACE Sep 23, 2018
@wglambert
Copy link

Similar wp-cli/wp-cli#4353 (comment)

@hairmare
Copy link

The manual states

Note: The GLOB_BRACE flag is not available on some non GNU systems, like Solaris.

Alpine ships with musl libc which is MIT and not GNU.

@tianon
Copy link
Member

tianon commented Sep 24, 2018

That's a bummer -- looks like there's nothing we can do here except recommend that if you require this constant, you need to switch to the Debian-based images off Alpine.

@tianon tianon closed this as completed Sep 24, 2018
@hairmare
Copy link

zend-stdlib has a fallback wrapper

\Zend\Stdlib\Glob::glob($pattern, $flags = 0, $forceFallback = false)

It can be installed with composer

composer require zendframework/zend-stdlib

@brandontamm
Copy link

brandontamm commented Jan 15, 2019

+1 for @hairmare's solution - it works!

I was building docker php container FROM php-7.0-fpm-alpine and trying to bin/magento setup:upgrade when I ran into the error:

[Exception]
Notice: Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' in /app/c
urrent/XXXXXX/vendor/zendframework/zend-stdlib/src/Glob.php on line 64

In my instance, my version of Magento (2.1.8) required using
composer require zendframework/zend-stdlib 2.4.13

@shiroamada
Copy link

That's a bummer -- looks like there's nothing we can do here except recommend that if you require this constant, you need to switch to the Debian-based images off Alpine.

what docker image can you recommended?

@tianon
Copy link
Member

tianon commented Nov 17, 2020

what docker image can you recommended?

If you're using php:7.4-fpm-alpine*, switch to php:7.4-fpm-buster instead, etc.

For further help, I'd suggest the Docker Community Forums, the Docker Community Slack, or Stack Overflow.

@docker-library docker-library locked as resolved and limited conversation to collaborators Nov 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants