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 extensions #8

Open
thekid opened this issue Aug 30, 2021 · 9 comments
Open

PHP extensions #8

thekid opened this issue Aug 30, 2021 · 9 comments
Labels
question Further information is requested

Comments

@thekid
Copy link
Member

thekid commented Aug 30, 2021

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)
@thekid
Copy link
Member Author

thekid commented Aug 30, 2021

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

@thekid thekid added the question Further information is requested label Aug 30, 2021
@thekid
Copy link
Member Author

thekid commented Sep 24, 2021

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

See #11

@thekid
Copy link
Member Author

thekid commented Sep 24, 2021

mbstring - prerequisite for exif anyways

See #12

@thekid
Copy link
Member Author

thekid commented Nov 11, 2021

@thekid
Copy link
Member Author

thekid commented Nov 11, 2021

@thekid
Copy link
Member Author

thekid commented Jul 14, 2022

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

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

@thekid
Copy link
Member Author

thekid commented Jul 14, 2022

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)

thekid added a commit that referenced this issue Jul 14, 2022
@thekid
Copy link
Member Author

thekid commented Jul 14, 2022

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

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

@thekid
Copy link
Member Author

thekid commented Aug 19, 2022

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
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant