Search code examples
phpherokulumendingo-apilumen-5.2

Lumen -> Error on line 54 - require(): Failed opening required


I install a fresh copy of Lumen as Heroku app. Also I implemented the packange Dingo into it: https://github.com/dingo/api/ but when I try to load everything server return me this error:

2016-02-14T11:07:45.657820+00:00 app[web.1]: [14-Feb-2016 11:07:45 UTC] PHP Warning:  require(/app/vendor/dingo/api/src/helpers.php): failed to open stream: No such file or directory in /app/vendor/composer/autoload_real.php on line 54
2016-02-14T11:07:45.657998+00:00 app[web.1]: [14-Feb-2016 11:07:45 UTC] PHP Fatal error:  require(): Failed opening required '/app/vendor/dingo/api/src/helpers.php' (include_path='.:/app/.heroku/php/lib
/php') in /app/vendor/composer/autoload_real.php on line 54

I tried to remove vendor folder, etc and reinstall it but result is the same

EDIT: My composer.json is:

{
    "name": "laravel/lumen",
    "description": "The Laravel Lumen Framework.",
    "keywords": ["framework", "laravel", "lumen"],
    "license": "MIT",
    "type": "project",
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.5.9",
        "laravel/lumen-framework": "5.2.*",
        "vlucas/phpdotenv": "~2.2",
        "dingo/api": "1.0.x@dev"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "phpunit/phpunit": "~4.0",
        "dingo/api": "1.0.x@dev"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/",
            "database/"
        ]
    }
}

EDIT 2: I tried now in my local machine and Lumen with Dingo works correctly so it's something with Heroku sigh. How to see Lumen Logs in Heroku Logs?


Solution

  • I think you missed to add configuration in your Heroku App. To make your Heroku app fetching all the composer requirements, you may run this on your root of Lumen App:

    heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
    

    Make a change again, then push your changes to heroku repository, eg:

    git push heroku master
    

    Edit

    To make this works, I have my own way to deploy Lumen App to Heroku.

    lumen new my-app
    cd my-app
    # Here you can change your composer.json dependencies
    composer require dingo/api
    

    Make your procfile

    vim Procfile
    
    # Content of Procfile
    web: vendor/bin/heroku-php-apache2 public
    

    Initialize repo

    git init
    git add -A .
    git commit -m "[INIT] Initial commit."
    

    Create Heroku app:

    heroku create
    heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
    git push heroku master
    

    Visit your heroku app.