-1

I'm trying to deploy a Symfony 5.2 on Heroku, I've already configured the Procfile and the required Config Vars such APP_ENV (prod), APP_SECRET and others related to the project.

Procfile:

web: vendor/bin/heroku-php-apache2 public/ 

composer.json:

{
"type": "project",
"license": "proprietary",
"require": {
    "php": "^7.2.5",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "knplabs/knp-paginator-bundle": "^5.2",
    "lexik/jwt-authentication-bundle": "^2.8",
    "nelmio/cors-bundle": "^2.0",
    "sensio/framework-extra-bundle": "^5.5",
    "symfony/asset": "5.1.*",
    "symfony/console": "5.1.*",
    "symfony/dotenv": "5.1.*",
    "symfony/flex": "^1.3.1",
    "symfony/framework-bundle": "5.1.*",
    "symfony/mailer": "5.1.*",
    "symfony/orm-pack": "^1.0",
    "symfony/security-bundle": "5.1.*",
    "symfony/serializer": "5.1.*",
    "symfony/yaml": "5.1.*",
    "twig/twig": "^3.0"        
},
"require-dev": {
    "doctrine/doctrine-fixtures-bundle": "^3.3",
    "symfony/maker-bundle": "^1.19",
    "symfony/profiler-pack": "^1.0"
},
"config": {
    "optimize-autoloader": true,
    "preferred-install": {
        "*": "dist"
    },
    "sort-packages": true
},
"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
},
"autoload-dev": {
    "psr-4": {
        "App\\Tests\\": "tests/"
    }
},
"replace": {
    "paragonie/random_compat": "2.*",
    "symfony/polyfill-ctype": "*",
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php72": "*",
    "symfony/polyfill-php71": "*",
    "symfony/polyfill-php70": "*",
    "symfony/polyfill-php56": "*"
},
"scripts": {
    "auto-scripts": {
        "cache:clear": "symfony-cmd",
        "assets:install %PUBLIC_DIR%": "symfony-cmd"
    },
    "post-install-cmd": [
        "@auto-scripts"
    ],
    "post-update-cmd": [
        "@auto-scripts"
    ],
    "compile": [
        "php bin/console doctrine:migrations:migrate"
    ]
},
"conflict": {
    "symfony/symfony": "*"
},
"extra": {
    "symfony": {
        "allow-contrib": false,
        "require": "5.1.*"
    }
}

}

No matter what I do I always end up with an error related to something missing such as:

PHP Fatal error:  Uncaught Error: Class 'Symfony\Bundle\TwigBundle\TwigBundle' not found in /tmp/build_271a300c_/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:74

My guess is the problem is related with everything ending up in this /tmp/build_271a300c_ folder and when the project is deployed it lost the refereed folder. But I have no idea what to do with this information I appreciate any help.

Felipe Chagas
  • 441
  • 1
  • 6
  • 19

1 Answers1

-1

Solved the problem with, what I think, is nothing more than a workaround.

The deploy process was complaining always about the require-dev dependencies, so I did:

  • Moved all require-dev to require;
  • Run composer update to refresh the composer.lock file;
  • Pushed and tried the deploy again with success.

This solution was take for many people in other issues I read, I'm just describing step-by-step what was done to fix it. Still, I don't think it's the correct fix for this, after all the dev-dependencies shouldn't being installed on prod environment.

Felipe Chagas
  • 441
  • 1
  • 6
  • 19
  • The error you mention in your question is completely unrelated to 'dev' dependencies. So your answer is confusing regarding the question. If your problem is that you want to install dev dependencies on heroku, see [this answer](https://stackoverflow.com/a/58597579/1426539). – yivi Jan 18 '21 at 07:22
  • Yes, it's not related. But somehow it worked, and as I said on the answer, it's a workaround. Anyway, it solved the problem and bought some time to learn about the correct way to do it. Wich I'm still looking for. – Felipe Chagas Jan 18 '21 at 13:43
  • If you read the linked answer (and the linked docs therein), you'll know that there is no way to make heroku build process install dev dependencies. The "correct way to do it" is to not depend on `require-dev` dependencies for deployed code. – yivi Jan 18 '21 at 13:55