0

Working all day to deploy my application to heroku, but every time it throws out an error. And i am all out of clues, and have a very angry customer.

When i try to add my project to heroku with the command git push heroku master every thing is fine till the cache needs to be cleared.

Updating the "app/config/parameters.yml" file
remote:        > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
remote:        > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
remote:        Could not open input file: app/console
remote:        Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception
remote:
remote:
remote:          [RuntimeException]
remote:          An error occurred when executing the "'cache:clear --no-warmup'" command:
remote:          Could not open input file: app/console
remote:          .

You would think, it's the same as this git issue

Also a know problem, that i am using a wrong type of mapping.

enter image description here

But i think it's fine.

I updated my composer and cleared the cache of my composer

And when i clear the cache with php bin/console cache:clear everything is fine!

I followed this tutorial And got some side information from the symfony site.

Also found this stack - with the explanation what is going on, but this is still not solving my problem.

Maybe it's somewhere in my composer file, or my git ignore. But honestely, i have no idea anymore.

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-4": { "": "src/" },
        "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
    },
    "autoload-dev": {
        "psr-4": { "Tests\\": "tests/" }
    },
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.1.*",
        "doctrine/orm": "^2.5",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-cache-bundle": "^1.2",
        "symfony/swiftmailer-bundle": "^2.3",
        "symfony/monolog-bundle": "^2.8",
        "symfony/polyfill-apcu": "^1.0",
        "sensio/distribution-bundle": "^5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "friendsofsymfony/user-bundle": "~2.0@dev",
        "symfony/assetic-bundle": "^2.8",
        "stfalcon/tinymce-bundle": "2.0",
        "egeloen/ckeditor-bundle": "^4.0",
        "whiteoctober/tcpdf-bundle": "^1.0",
        "gregwar/captcha-bundle": "^2.0"
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0"
    },
    "scripts": {
        "symfony-scripts": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ],
        "compile": [
            "rm web/app_dev.php",
            "bin/console cache:clear",
            "bin/console assetic:dump"
        ]
    },
    "config": {
        "platform": {
            "php": "5.5.9"
        }
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-bin-dir": "bin",
        "symfony-var-dir": "var",
        "symfony-web-dir": "web",
        "symfony-tests-dir": "tests",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "3.1-dev"
        }
    }
}
10
  • 1
    Strange bin/console is a Symfony3 command, and app/console is a Symfony2 command. I wonder if that has something to do with it? Commented Jan 6, 2017 at 22:10
  • 1
    Yes, app/console is used for symfony2, while symfony3 is using bin/console. Commented Jan 6, 2017 at 22:12
  • That's my point, maybe you need to use Symfony version 2.7 instead of version 3.1 (or 2.8), since the directory structure has changed. I'm not sure if you can change the symfony version or not. Commented Jan 6, 2017 at 22:28
  • I can change the symfony version, but i don't really want to and heroku supports symfony3. Also see this link - stackoverflow.com/questions/34198591/… Commented Jan 6, 2017 at 22:36
  • See @Aerendir 's answer. I agree with him. It appears you have a Symfony2 project. You need to update it to Symfony3. I've seen a lot of post on SO about users having problems converting from Symfony2 to symfony3; the reason being, they try to do it the easy way just like what you are trying to do. Commented Jan 6, 2017 at 22:45

3 Answers 3

1

The solution that worked for me. New Symfony 3 installation: Could not open input file: app/console in composer install

EXPLANATION:

That's what I guess. When you push your code to Heroku, the platform compiles your project files on the /tmp dir. What happens if you don't have a var dir when Heroku compiles your code? What happens is that Symfony creates a new one:

vendor/sensio/distribution-bundle/Composer/ScriptHandler.php:462

protected static function useNewDirectoryStructure(array $options)
{
    return isset($options['symfony-var-dir']) && is_dir($options['symfony-var-dir']);
}

Then when Heroku moves your new code to the /appdir, the Symfony configuration still points to the old placement /tmp, but files placed at /tmp are now deleted!

Sign up to request clarification or add additional context in comments.

1 Comment

This fixed my problem
1

You upgraded a Symfony 2 app to 3.

But it is not sufficient to change the requirements in composer.json.

The structure changed, so you need to first create a new fresh app with Symfony 3 and then move the old Symfony 2 app to the fresh Symfony 3 one, bundle by bundle, composer requirement by composer requirement.

This way you'll be sure your app will work well on version 3.

If you try to simply upgrade the requirements from a Symfony 2 app, then you'll create a lot of bugs, as the scripts changed, the structure changed, the requirements changed...

The only safe way is to start a new Symfony 3 project and then port the old Symfony 2 into it.

3 Comments

I used this command composer create-project symfony/framework-standard-edition my_project_name Two months ago, and it installed symfony3, but i can try the sollution with a new project.
Use the Symfony installer instead of composer itself: symfony.com/doc/current/setup.html
Reading your composer, it seems you installed the version 3.1. I apply the same procedure also to upgrade between minor versions (for example, to upgrade from 2.6 to 2.7 and from 2.7 to 2.8).
0

I took a look at your github repository. Seems like it's in the Symfony3 format, so I'm not certain what is going on. I want to try something, but I'm not sure if it will work.

Try editing your composer.json file manually to add the bin directory:

"config": {
        "bin-dir": "bin",
        "platform": {
            "php": "5.5.9"
        }
},

Then see if that fixes the problem.


EDIT #2

Now revert those changes and try this:

"extra": {
    "symfony-app-dir": "bin",
    "symfony-bin-dir": "bin",
    "symfony-var-dir": "var",

In other words change the app directory to "bin".

2 Comments

it is giving the same result, also cleared my cache again (composer and symfony)
That shows symfony-app-dir as still being "app", but instead I need that changed to "bin".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.