Skip to content

PHP extensions #8

Open
Open

Description

@thekid

Currently, we compile with the following extensions enabled:

  • Core
  • bcmath
  • ctype
  • date
  • fileinfo
  • filter
  • hash
  • iconv
  • json
  • openssl
  • pcre
  • Phar
  • posix
  • Reflection
  • session
  • SPL
  • standard
  • tokenizer

Looking at https://bref.sh/docs/environment/php.html#extensions-installed-and-enabled and from scanning through use cases, the following could be interesting:

  • gd, exif - image processing
  • mbstring - prerequisite for exif anyways
  • sodium - for crypto
  • zlib - if we want to create ZIP files, HTTP compression - see PHP extensions #8 (comment)
  • sqlite3 - for temporary data storage
  • libxml, dom, xml, xmlreader, xmlwriter - for processing XML and HTML - see Enable XML extensions #11

The following extensions don't seem to make sense for an AWS lambda enviromment:

  • pcntl - for parallelization, you would most probably just invoke other lambdas and/or use a message queue
  • readline - this is for humans sitting in front of a terminal, not for the serverside
  • curl, ftp, mysqli / mysqlnd - the XP Framework has it's own protocol implementations
  • sockets - the standard socket library works just as well for (most - or almost all?) cases
  • opcache - we leave our code running after compiling once, caching doesn't improve this any more
  • SimpleXML - covered by XP Framework's XML APIs - used by AWS SDK, see PHP extensions #8 (comment)

Activity

  1. thekid commented on Aug 30, 2021

    @thekid
    MemberAuthor

    However, all these increase the PHP binary size, it might be valuable looking into providing these as extra layers like Bref does, but instead of hosting them somewhere, providing a xp lambda layer command to create them from scratch

  2. thekid commented on Sep 24, 2021

    @thekid
    MemberAuthor

    libxml, dom, xml, xmlreader, xmlwriter - for processing XML and HTML

    See #11

  3. thekid commented on Sep 24, 2021

    @thekid
    MemberAuthor

    mbstring - prerequisite for exif anyways

    See #12

  4. thekid commented on Nov 11, 2021

    @thekid
    MemberAuthor
  5. thekid commented on Jul 14, 2022

    @thekid
    MemberAuthor

    ZLib could be implemented via https://gist.github.com/chobie/6659137 as a fallback:

    "You can use my implementation freely even for commercial purpose ..."

  6. thekid commented on Jul 14, 2022

    @thekid
    MemberAuthor

    ZLib could be implemented

    ...but on the other hand, simply adding the --with-zlib configure option doesn't yield a big difference!

    Before:

    [+] Creating runtime-8.0.21.zip
     => create --name 62d00678ec295 lambda-xp-runtime:8.0.21
    aeb956bff0da38d5254234ca63e3594a5f6f9dff9ed485353cd08557194d4fef
     => cp 62d00678ec295:/opt/php/runtime.zip runtime-8.0.21.zip
     => rm -f 62d00678ec295
    aeb956bff0da38d5254234ca63e3594a5f6f9dff9ed485353cd08557194d4fef
    
    Wrote 2,530,040 bytes
    

    After:

    [+] Creating runtime-8.0.21.zip
     => create --name 62d008947c97a lambda-xp-runtime:8.0.21
    bd517bac950db0f3542c93ba2ef63faeeb991b5873b5b083b3c8282ebb5094d8
     => cp 62d008947c97a:/opt/php/runtime.zip runtime-8.0.21.zip
     => rm -f 62d008947c97a
    bd517bac950db0f3542c93ba2ef63faeeb991b5873b5b083b3c8282ebb5094d8
    
    Wrote 2,542,744 bytes
    

    (~12 Kilobytes)

  7. added a commit that references this issue on Jul 14, 2022
  8. thekid commented on Jul 14, 2022

    @thekid
    MemberAuthor

    zlib - if we want to create ZIP files, HTTP compression

    Rolled out in https://github.com/xp-forge/lambda/releases/tag/v4.1.0

  9. thekid commented on Aug 19, 2022

    @thekid
    MemberAuthor

    The configure line used is:

    ./configure \
      --prefix=/opt/php/ \
      --without-sqlite3 \
      --with-zlib \
      --with-openssl \
      --enable-bcmath \
      --disable-pdo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions