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

Load extension dynamically #26

Closed
t-geindre opened this issue Jun 13, 2018 · 4 comments · Fixed by #29
Closed

Load extension dynamically #26

t-geindre opened this issue Jun 13, 2018 · 4 comments · Fixed by #29

Comments

@t-geindre
Copy link
Contributor

As done in #14 with opcache.so, I tried to load more extensions dynamically.

I was able to compile Redis and MongoDB extensions with a bit tweaked version of bin/php/Dockerfile and bin/php/build.sh.

Then I created a tar archive containing those two extensions in the ext directory.

And finally I used the following hook to make php binary load those extensions:

hooks:
    build:
        # Add custom extensions to php.ini
        - 'echo "extension=mongodb.so" >> .bref/php.ini'
        - 'echo "extension=redis.so" >> .bref/php.ini'

A phpinfo() confirms that those two extensions are correctly loaded.

I think this could be done in a better way, especially the php.ini update.

What do you think?

@t-geindre
Copy link
Contributor Author

t-geindre commented Jun 15, 2018

I had an idea: each php archive could provide its own php.ini file, allowing it to load all provided extensions, including opcache.

@mnapoli
Copy link
Member

mnapoli commented Jun 19, 2018

This is a nice solution. However we could also go with a solution similar to, for example, platform.sh: https://docs.platform.sh/languages/php/ini.html

We could allow to set php.ini values in .bref.yml, for example:

php:
    configuration:
        memory_limit: 256M

For enabling extensions:

php:
    extensions:
        - mongodb
        - redis

I am 100% for building and including standard extensions into Bref, I just don't want to enable all of them by default to avoid slowing down PHP's start time (since we start a PHP process on every request).

So if we are talking about redis and mongodb I think it would be way better to build them in build.sh and the Dockerfile by default, and enable them with .bref.yml as shown above.

Later, if someone wants to build its own custom extension, then we can find a solution. But I think it's a rare use case, it's fine if we don't address it right now.

What do you think?

@t-geindre
Copy link
Contributor Author

t-geindre commented Jun 20, 2018

Ok I though the idea was to provide the simplest package possible and let users to create their own. If you're ok to provide all standard extensions, then you're right, we should enable them in .bref.yml..

I'll close #28 and make a new one.

@mnapoli
Copy link
Member

mnapoli commented Jun 20, 2018

Great. Yeah I think many people will want to use redis and/or mongodb so that's great if it's 1 line of code to enable it, instead of recompiling PHP from scratch.

brefphp-bot pushed a commit to brefphp-bot/bref that referenced this issue Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants