A Cloud Foundry buildpack for PHP based apps.
This is based on the Heroku buildpack.
Additional documentation can be found at CloudFoundry.org.
This buildpack will be used if there is a composer.json
or index.php
file in the root directory of your project.
cf push my_app -b https://github.com/cloudfoundry/cf-buildpack-php.git
The primary purpose of extending the heroku buildpack is to cache system dependencies for firewalled or other non-internet accessible environments. This is called 'offline' mode.
'offline' buildpacks can be used in any environment where you would prefer the dependencies to be cached instead of fetched from the internet.
The list of what is cached is maintained in bin/package.
Using cached system dependencies is accomplished by overriding curl during staging. See bin/compile
Offline mode expects each app to use composer to manage dependencies. Use composer install
to vendor your dependencies into /vendor
.
There are three supported behaviors if the app has no dependencies:
-
If index.php exists, the app does not need a composer.json file.
-
The app can have an empty composer.json file:
touch composer.json
-
The app can explicitly disable the default Packagist repository:
echo '{"repositories":[{"packagist":false}]}' > composer.json
- Make sure you have fetched submodules
git submodule update --init
- Build the buildpack
bin/package [ online | offline ]
-
Use in Cloud Foundry
Upload the buildpack to your Cloud Foundry and optionally specify it by name
cf create-buildpack custom_php_buildpack php_buildpack-offline-custom.zip 1 cf push my_app -b custom_php_buildpack
There are Machete based integration tests available in cf_spec.
The test script is included in machete and can be run as follows:
BUNDLE_GEMFILE=cf.Gemfile bundle install
git submodule update --init
`BUNDLE_GEMFILE=cf.Gemfile bundle show machete`/scripts/buildpack-build [mode]
buildpack-build
will create a buildpack in one of two modes and upload it to your local bosh-lite based Cloud Foundry installations.
Valid modes:
online : Dependencies can be fetched from the internet.
offline : System dependencies, such as python, are installed from a cache included in the buildpack.
The tests expect two Cloud Foundry installations to be present, an online one at 10.244.0.34 and an offline one at 10.245.0.34.
We use bosh-lite for the online instance and bosh-lite-2nd-instance for the offline instance.
- Fork the project
- Submit a pull request
Open an issue on this project
The project backlog is on Pivotal Tracker