Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

Allow layers to load extra ini files #6

Merged

Conversation

JerryVerhoef
Copy link
Contributor

When you create new layers which would load additional extensions you need to be able to load extra ini files. This change will enable this in an easy way. Futhermore this will also enable lambda function to create their own php.ini overrides

For Layers:
Layers should add ini files to etc/php-7.1.d in the zip file it will be automatically be picked up during the bootstrap

For Lambda:
Add you custom ini files to /php-7.1.d and the bootstrap will apply them.

@JerryVerhoef JerryVerhoef force-pushed the fix-scan-additional-php-ini-files branch from f413690 to 9c4871b Compare December 3, 2018 00:18
Copy link
Member

@txase txase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/opt/etc/php-7.1.d/ makes perfect sense. Help me understand the function package scan dir and we'll be all set :).

🙏

@@ -15,7 +15,7 @@ function start_webserver() {
// exec the command
$HANDLER = getenv('_HANDLER');
chdir('/var/task');
exec("php -S localhost:8000 -c /var/task/php.ini -d extension_dir=/opt/lib/php/7.1/modules '$HANDLER'");
exec("PHP_INI_SCAN_DIR=/opt/etc/php-7.1.d/:/var/task/php-7.1.d/ php -S localhost:8000 -c /var/task/php.ini -d extension_dir=/opt/lib/php/7.1/modules '$HANDLER'");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sincere question: why add /var/task/php-7.1.d/ when you can simply put a php.ini file at the root of the function package?

Is it a convention (if so, please provide a link to example(s))?

@JerryVerhoef
Copy link
Contributor Author

JerryVerhoef commented Dec 3, 2018 via email

Copy link
Member

@txase txase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It all makes sense to me, and provides helpful flexibility. 🚀

@@ -63,7 +63,9 @@ extension=json.so

Extensions can be built using the lambci/lambda:build-nodejs8.10 Docker image. It is recommended that custom extensions be provided by a separate Lambda Layer with the extension .so files placed in /lib/php/7.1/modules/ so they can be loaded alongside the built-in extensions listed above.

#### Example
The extensions can be loaded by adding an ini file in the etc/php-7.1.d this will be picked up automatically
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to edit this a bit post-merge to make it clearer for both layer and package code.

@txase txase merged commit 2f32b04 into stackery:master Dec 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants