Giter VIP home page Giter VIP logo

Comments (5)

hype09 avatar hype09 commented on August 13, 2024 2

Actually, I believe I have found the reason: The Polyfill seems not to be included in the final phpbu.phar distribution file:

phar list -f phpbu.phar | grep polyfill-mbstring
# 0 results

I believe the Phar file is built by copying dependencies over via a "whitelist":

phpbu/build.xml

Lines 453 to 461 in b65da0c

<!-- Symfony libs -->
<copy file="${basedir}/vendor/symfony/options-resolver/LICENSE"
tofile="${basedir}/build/phar/lib/symfony/options-resolver/LICENSE"/>
<copy todir="${basedir}/build/phar/lib/symfony/options-resolver">
<fileset dir="${basedir}/vendor/symfony/options-resolver">
<include name="**/*.php"/>
<exclude name="**/Test*"/>
</fileset>
</copy>

E.g.: The current distribution only contains symfony/options-resolver, but not the other symfony/* dependencies, such as the polyfill:

  • deprecation-contracts
  • polyfill-ctype
  • polyfill-mbstring
  • polyfill-php80
  • process
  • var-dumper

I am not sure why the dependencies are copied one-by-one, rather than adding all of them. Perhaps distribution size? But even then I would guess adding everything and then removing the ones that are definitely not needed (aka. blacklist rather than whitelist) would make for more stable release package while keeping release sizes reasonable.

from phpbu.

planetahuevo avatar planetahuevo commented on August 13, 2024

possible solution here:
https://stackoverflow.com/questions/6419102/fatal-error-call-to-undefined-function-mb-strlen

from phpbu.

hype09 avatar hype09 commented on August 13, 2024

Hm, this puzzles me a bit. Can you provide more information on the type of environment you run phpbu in: PHP version, OS, Shared Hosting, phpbu version, ...?

This usage of mb_strlen comes from a transitive dependency: phpbu uses aws/aws-sdk-php, which uses mtdowling/jmespath.php, which uses mb_strlen. However, that last one also requires symfony/polyfill-mbstring, which should transparently add the function in the global namespace, if it doesn't exist. So I am wondering how we're even getting to this message...

from phpbu.

planetahuevo avatar planetahuevo commented on August 13, 2024

Well, is a VPS with docker and no public php server. So the php installed there is the default ubuntu one, which lacks the mbstring.
Installing apt-get install php7.4-mbstring solve the issue and works, but yeah, I wondered the same thing.

Ubuntu 22.04, php 7.4, latest phpbu version. VPS.

from phpbu.

sebastianfeldmann avatar sebastianfeldmann commented on August 13, 2024

Yes the main reason for the whitelist was file size at some point.
But I think changing it to a blacklist would be the better option.
That does not remove the burden of knowing every dependency that goes into the PHAR.
The Symfony polyfills are a good example. Including the classes into the PHAR is not enough.
The polyfill setup hast to be manually called within the PHAR

    // load the symfony polyfills
    require __PHPBU_PHAR_ROOT__ . '/lib/symfony/polyfill-ctype/bootstrap.php';
    require __PHPBU_PHAR_ROOT__ . '/lib/symfony/polyfill-mbstring/bootstrap.php';
    require __PHPBU_PHAR_ROOT__ . '/lib/symfony/polyfill-php80/bootstrap.php';

I think 470ab12 fixes the issue

from phpbu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.