Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Enable extensions declared in composer.json (#245)
Browse files Browse the repository at this point in the history
* Add script to parse composer.json for extensions to enable and enable them

* Add tests for the detect php version and install extensions scripts

* Fix cs style

* Extra whitespace

* No reason to handle shared vs. debian packaged extensions separate for now

* Run all the extension tests using the extension enabler rather than declaring in the custom php.ini file

* fix installation of bcmath, raphf, pq

* Fail if an extension is not available or if the extension version requested is not '*'

* Fix cs

* Maintain a blacklist of unsupported extensions/php versions

* Fix variable name

* Fix output file for the extensions.ini file

* Update README for note on installing extensions
  • Loading branch information
chingor13 authored Apr 12, 2017
1 parent f5cf12d commit 689fb82
Show file tree
Hide file tree
Showing 24 changed files with 1,668 additions and 144 deletions.
6 changes: 4 additions & 2 deletions php-nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ RUN chgrp www-data composer.sh && chmod +x /entrypoint.sh /composer.sh \

# A script for extracting PHP version from composer.json.
COPY detect_php_version.php /tmp/detect_php_version.php
RUN chgrp www-data /tmp/detect_php_version.php && cd /tmp \
&& su www-data -c "php /usr/local/bin/composer require composer/semver"
COPY install_extensions.php /tmp/install_extensions.php
RUN chgrp www-data /tmp/detect_php_version.php && \
cd /tmp && \
su www-data -c "php /usr/local/bin/composer require composer/semver"

# Copy the app and change the owner
ONBUILD COPY . $APP_DIR
Expand Down
39 changes: 35 additions & 4 deletions php-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,27 @@ php.ini):

- BCMath (bcmath)
- Calendar (calendar)
- Cassandra (cassandra, third-party)
- Ev (ev)
- Event (event)
- Exif (exif)
- FTP (ftp)
- GD (gd; with PNG, JPEG and FreeType support)
- gettext (gettext)
- gRPC (shared)
- gRPC (grpc)
- intl (intl)
- ImageMagick (imagick)
- mbstring (mbstring)
- memcached (shared, enabled by default, experimental support for PHP7)
- mongodb (shared)
- memcached (enabled by default, experimental support for PHP7)
- mongodb (mongodb)
- MySQL (mysql; it's removed with PHP7.0)
- OAuth (oauth)
- PCNTL (pcntl)
- redis (shared)
- Phalcon (phalcon, not available for PHP 7.1)
- PostgreSQL (pq, also requires raphf)
- RAPHF (raphf)
- rdkafka (rdkafka)
- redis (redis)
- Shmop (shmop)
- SOAP (soap)
- SQLite3 (sqlite3)
Expand All @@ -252,6 +261,28 @@ These extensions are only available with PHP 7:

- APCu-BC (shared, enabled by default)

### Enabling extensions

To enable extensions, you can either [use a custom php.ini file]
(#add-something-to-phpini) or declare the requirement in your
`composer.json`. To add the requirement to your `composer.json`,
either run:

```bash
> composer require ext-<extension name>:*
```

or add `"ext-<extension name>": "*"` to your `composer.json` in the
`require` section:

```json
{
"require": {
"ext-phalcon": "*"
}
}
```

## Add something to php.ini

You can just have php.ini file in your project directory. This file is
Expand Down
2 changes: 2 additions & 0 deletions php-nginx/build-scripts/install_php56.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ apt-get install -y \
--no-install-recommends

# Enable some extensions for backward compatibility
ln -s ${PHP56_DIR}/bin/php56-enmod ${PHP56_DIR}/bin/php-enmod
ln -s ${PHP56_DIR}/bin/php56-dismod ${PHP56_DIR}/bin/php-dismod
${PHP56_DIR}/bin/php56-enmod apcu
${PHP56_DIR}/bin/php56-enmod json
${PHP56_DIR}/bin/php56-enmod mailparse
Expand Down
2 changes: 2 additions & 0 deletions php-nginx/build-scripts/install_php70.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ apt-get install -y \
--no-install-recommends

# Enable some extensions for backward compatibility
ln -s ${PHP70_DIR}/bin/php70-enmod ${PHP70_DIR}/bin/php-enmod
ln -s ${PHP70_DIR}/bin/php70-dismod ${PHP70_DIR}/bin/php-dismod
${PHP70_DIR}/bin/php70-enmod apcu-bc
${PHP70_DIR}/bin/php70-enmod mailparse
${PHP70_DIR}/bin/php70-enmod memcached
Expand Down
2 changes: 2 additions & 0 deletions php-nginx/build-scripts/install_php71.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ apt-get install -y \
--no-install-recommends

# Enable some extensions for backward compatibility
ln -s ${PHP71_DIR}/bin/php71-enmod ${PHP71_DIR}/bin/php-enmod
ln -s ${PHP71_DIR}/bin/php71-dismod ${PHP71_DIR}/bin/php-dismod
${PHP71_DIR}/bin/php71-enmod apcu-bc
${PHP71_DIR}/bin/php71-enmod mailparse
${PHP71_DIR}/bin/php71-enmod memcached
Expand Down
8 changes: 8 additions & 0 deletions php-nginx/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"require": {
"composer/semver": "*"
},
"require-dev": {
"phpunit/phpunit": "4.8.*"
}
}
Loading

0 comments on commit 689fb82

Please sign in to comment.