dunglas / api-platform-heroku
Helpers to use API Platform and Symfony applications on Heroku.
Fund package maintenance!
dunglas
Installs: 3 873
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 1
Open Issues: 9
Requires
- php: >=5.3
Requires (Dev)
- phpunit/phpunit: ~4.6
Suggests
- dunglas/api-platform: To build awesome modern API-first web apps
- symfony/symfony: To build awesome web apps
This package is auto-updated.
Last update: 2024-10-27 03:05:24 UTC
README
This library eases the deployment of API Platform and Symfony applications on the Heroku platform.
Install
Use Composer to install the library in your project:
composer require dunglas/api-platform-heroku
Database helper
The library provides a Composer script to create Symfony parameters for the Doctrine bundle by parsing the DATABASE_URL
environment variable populated by the Heroku Postgres addon.
To use it, start by adding the script to your composer.json
file:
// ... "scripts": { "pre-install-cmd": [ "Dunglas\\Heroku\\Database::createParameters" ], // ... }
Thanks to the ability of the Symfony Dependency Injection Component to read parameters from special environment variables, the parameters are automatically populated.
Change the content of the app/config/services.yml
like the following to use them:
doctrine: dbal: driver: "pdo_pgsql" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: UTF8
In your local development environment, don't forget to set the SYMFONY__DATABASE_URL
environment variable.
A typical value for that variable is `postgres://user:pass@server:5432/dbname.
A convenient way to manage environment variable is the PHP dotenv library.
Credits
This library is part of the API Platform project. Created by Kévin Dunglas.