Date
1 - 6 of 6
[ PHP ] Best config practices
Leandro David Cacciagioni
I have a php monolith app that requires tons of .ini files config previous
to the deployment I want to know if any of you have a "best practice" to generate all this ini files depending from the environmental variables.
|
|
Daniel Mikusa
You can include a `.profile.d/` script or a `.profile` script. It depends
on exactly what you're trying to do as to which one would be better to use, but I believe most of the time you'd want the `.profile` script. You can see more about it in the docs here. https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html#profile You can essentially do whatever you want in this script. Plus you'll have access to everything that the PHP build pack has configured for you and you'll have access to all the environment variables. This means you can run PHP scripts or examine VCAP_SERVICES. The only catch is that these scripts runs prior to your application starting so they must run and your application must start within the defined timeout (default 60s, max 180s on most platforms). If you want to integrate with the build pack and do something during staging or if you need more time (cause staging typically runs for up to 900s), you can add a build pack extension. These are written in Python and run as a part of the build pack. Instructions on doing that can be found here. https://github.com/cloudfoundry/php-buildpack#extensions Hope that helps! Dan On Thu, Jan 19, 2017 at 4:01 PM, Leandro David Cacciagioni < leandro.21.2008(a)gmail.com> wrote: I have a php monolith app that requires tons of .ini files config previous
|
|
Nicholas Calugar
You may also want to look into [1] .user.ini files.
toggle quoted messageShow quoted text
+Steven Would you consider compiling PHP with this option: --with-config-file-scan-dir /home/vcap/app/php/etc/php.d And then providing some mechanism for the buildpack to copy .ini files from a known location into that directory? [1] http://php.net/manual/en/configuration.file.per-user.php -- Nicholas Calugar
On January 20, 2017 at 5:36:45 AM, Daniel Mikusa (dmikusa(a)pivotal.io) wrote:
You can include a `.profile.d/` script or a `.profile` script. It depends on exactly what you're trying to do as to which one would be better to use, but I believe most of the time you'd want the `.profile` script. You can see more about it in the docs here. https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html#profile You can essentially do whatever you want in this script. Plus you'll have access to everything that the PHP build pack has configured for you and you'll have access to all the environment variables. This means you can run PHP scripts or examine VCAP_SERVICES. The only catch is that these scripts runs prior to your application starting so they must run and your application must start within the defined timeout (default 60s, max 180s on most platforms). If you want to integrate with the build pack and do something during staging or if you need more time (cause staging typically runs for up to 900s), you can add a build pack extension. These are written in Python and run as a part of the build pack. Instructions on doing that can be found here. https://github.com/cloudfoundry/php-buildpack#extensions Hope that helps! Dan On Thu, Jan 19, 2017 at 4:01 PM, Leandro David Cacciagioni < leandro.21.2008(a)gmail.com> wrote: I have a php monolith app that requires tons of .ini files config previous
|
|
Leandro David Cacciagioni
Thanks a lot guys it is a great help!!!!
toggle quoted messageShow quoted text
2017-01-20 19:27 GMT+01:00 Nicholas Calugar <ncalugar(a)pivotal.io>:
You may also want to look into [1] .user.ini files.
|
|
Daniel Mikusa
On Fri, Jan 20, 2017 at 1:27 PM, Nicholas Calugar <ncalugar(a)pivotal.io>
wrote: You may also want to look into [1] .user.ini files.This is probably not necessary as there's a bunch of ways to override PHP config currently. You mentioned `.user.ini` files which is a great option, you can also use `.htaccess` files assuming you're using HTTPD which is the default web server configured by the build pack, you can override the entire default build pack php.ini with the method mentioned here [2] and you can do dynamic generation as I mentioned in `.profile` / `.profile.d`. Dan [2] - https://docs.cloudfoundry.org/buildpacks/php/gsg-php-config.html#engine-configurations
|
|
Nicholas Calugar
Dan,
toggle quoted messageShow quoted text
I’m concerned that .user.ini and .htaccess files are processed for every request. This is a no-no for production apps. As for overriding the entire php.ini, I’m in favor of extensibility. This way when a new version of PHP ships with a new default php.ini, I don’t have to update my application. Do you have an example of how to override PHP configuration in an extensible manner? -Nick -- Nicholas Calugar
On January 20, 2017 at 10:49:59 AM, Daniel Mikusa (dmikusa(a)pivotal.io)
wrote: On Fri, Jan 20, 2017 at 1:27 PM, Nicholas Calugar <ncalugar(a)pivotal.io> wrote: You may also want to look into [1] .user.ini files.This is probably not necessary as there's a bunch of ways to override PHP config currently. You mentioned `.user.ini` files which is a great option, you can also use `.htaccess` files assuming you're using HTTPD which is the default web server configured by the build pack, you can override the entire default build pack php.ini with the method mentioned here [2] and you can do dynamic generation as I mentioned in `.profile` / `.profile.d`. Dan [2] - https://docs.cloudfoundry.org/buildpacks/php/gsg-php-config.html#engine-configurations
|
|