GithubHelp home page GithubHelp logo

api-platform-heroku's Introduction

API Platform and Symfony helpers to deploy on Heroku

This library eases the deployment of API Platform and Symfony applications on the Heroku platform.

Build Status Scrutinizer Code Quality SensioLabsInsight Dependency Status

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.

api-platform-heroku's People

Contributors

dunglas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jmalbert

api-platform-heroku's Issues

Error on Procfile?

I got this error now:

2018-01-05T13:49:26.279740+00:00 heroku[web.1]: Starting process with command `bin/heroku-php-apache2 web/`
2018-01-05T13:49:27.711200+00:00 app[web.1]: bash: bin/heroku-php-apache2: No such file or directory
2018-01-05T13:49:27.777956+00:00 heroku[web.1]: State changed from starting to crashed

I will investigate...

Please, tag a stable version :)

We are forced to setup "minimum-stability" : "dev" in order to use this package, this is unusable except for testing purposes :)

DATABASE_URL is not available when pushing with app.json

I see that you have a heroku addon on the app.json, but when pushing to heroku, it was saying that DATABASE_URL was not available anyway. So I had to install it with:

heroku addons:create heroku-postgresql:hobby-dev

After that, that error stopped happening.

Dunglas\Heroku\Database not on autorun

When deploying I was not able to put that class on autorun. I did it locally by running composer update. But was not able to do it on heroku.

So I decided to use this that seemed a better approach than having to rely on that Database::createParameters method:

doctrine:
    dbal:
        driver: pdo_mysql
        url: "%env(DATABASE_URL)%"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.