cloudfoundry / php-buildpack

A Cloud Foundry Buildpack for PHP.
Apache License 2.0
142 stars 347 forks source link

PHP v2b buildpack does not load extensions from *.ini files #426

Closed fg-j closed 3 years ago

fg-j commented 4 years ago

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version?

{
   "name": "",
   "build": "",
   "support": "",
   "version": 0,
   "description": "",
   "authorization_endpoint": "https://login.porcupine.cf-app.com",
   "token_endpoint": "https://uaa.porcupine.cf-app.com",
   "min_cli_version": null,
   "min_recommended_cli_version": null,
   "app_ssh_endpoint": "ssh.porcupine.cf-app.com:2222",
   "app_ssh_host_key_fingerprint": "V9Zi9319g6MDZFTsKjKk4hQN1GFz4RtZr9tBHv+Db8w",
   "app_ssh_oauth_client": "ssh-proxy",
   "doppler_logging_endpoint": "wss://doppler.porcupine.cf-app.com:443",
   "api_version": "2.155.0",
   "osbapi_version": "2.15",
   "routing_endpoint": "https://api.porcupine.cf-app.com/routing",
   "user": "b9af6fe9-b435-4a9d-84e8-632fe45959e3"
}
cf version 6.50.0+4f0c3a2ce.2020-03-03

What version of the buildpack you are using? 4.4.24

As the following Github issues indicate, (https://github.com/cloudfoundry/php-buildpack/issues/378, https://github.com/cloudfoundry/php-buildpack/issues/341, https://github.com/cloudfoundry/php-buildpack/issues/360) there's an issue with the v2 php buildpack in which it does not load extensions from *.ini files as the docs suggest it should.

As this issue #341 indicates, composer users can work around this issue by adding a platform package for the desired extension. The buildpack will detect the requirement and pull in the necessary extension.

To quickly reproduce the issue:

  1. Clone this fork of the php-buildpack source and check out the ini-load-bug branch
  2. Focus the "deploying a basic PHP app using Cassandra module" test
  3. Run the integration tests: scripts/integration.sh

You should see a failure that looks something like:

got error 'PHP message: PHP Notice:  Undefined index: CfCommunity\\CfHelper\\CfHelper in /home/vcap/app/lib/vendor/sphring/sphring/src/Arthurh/Sphring/Runner/SphringRunner.php on line 62\nPHP message: PHP Fatal error:  Uncaught Error: Class 'Cassandra' not found in /home/vcap/app/htdocs/index.php:18\nStack trace:\n#0 {main}\n  thrown in /home/vcap/app/htdocs/index.php on line 18\n'

The expected behaviour is that Cassandra should be loaded as an extension, because it's specified in the .bp-config/php.ini.d/filename.ini file.

Please confirm where necessary:

cf-gitbot commented 4 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/175549373

The labels on this github issue will be updated when the story is started.

Tobion commented 3 years ago

The cassandra extension is removed from the buildpack from PHP >= 7.3 according to the release page. I guess because it's not compatible with newer php versions and not maintained anymore, see https://github.com/datastax/php-driver

So that could also explain why the extension is not loaded.

arjun024 commented 3 years ago

Hi @fg-j, In your example app, you were adding the ini at .bp-config/php.ini.d/filename.ini but per documentation you should be adding it at .bp-config/php/php.ini.d/filename.ini (Notice the missing php directory). Tested on the with_cassandra app from your example app and it works:

cf push app4424 -b php4424 -c "php -m" --health-check-type none && cf logs app4424 --recent

Output shows:

2020-12-16T16:46:19.12+0000 [APP/PROC/WEB/0] OUT cassandra

cc @thitch97