3

I have set up a new symfony 4 project that I am trying to deploy on heroku. I have the app set up and running successfully locally. I bascially followed the instructions from the heroku tutorial here. However, this tutorial is only written for symfony versions 2 and 3.

I had set up a symfony 3 app in the past successfully, I had to create a Procfile to direct the heroku server to the web/ directory, as per the instructions in the "Best Practices" section. In this S4 installation I don't see a web/ folder, so I didn't create a Procfile. Heroku uses a default command in this case.

I have created 2 config vars in heroku config: APP_ENV, SYMPHONY_ENV both are set to prod. I deploy the app the heroku, it all deployed successfully, but when I try to access the page, I just get a 403 Forbidden. In the logs I get this, which is maybe the correct functionality since I didn't write any code yet:

[autoindex:error] [pid 116:tid 139699079337728] [client 10.5.228.216:17171] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive

I don't see an app folder, but I do see a folder called public with an index file inside.

Does anyone have experience deploying the new version of Symfony 4 to Heroku, if so any tips would be greatly appreciated. Thanks!

4
  • 1
    have you tried it? the public root folder changed from 'web' to 'public' in Symfony 4. Commented Feb 22, 2018 at 13:57
  • @LBA i just tried it and thanks for the simple suggestion it seems to have worked, although now I am getting an execption: PHP Fatal error: Uncaught Symfony\Component\Routing\Exception\NoConfigurationException in /app/var/cache/prod/srcProdProjectContainerUrlMatcher.php Which seems like its OK since I haven't yet configured anything and this heroku server app is set to production Commented Feb 22, 2018 at 15:33
  • indeed - so simply continue and ask when you're stuck Commented Feb 22, 2018 at 15:40
  • @LBA yes thank you I put in the controller for the base route and the site works, seems silly. I should have tried earlier what you suggested but somehow it didn't seem obvious. Thanks. Commented Feb 22, 2018 at 19:23

3 Answers 3

1

On Symfony 4 the web folder was replaced by public. You still need to create the Procfile file and add this line:

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

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

Comments

1

In my case I defined a Procfile with the following content :

web: $(composer config bin-dir)/heroku-php-apache2 public/

But it was not enough, I had to install apache-pack with composer :

composer require apache-pack (using symfony flex) or composer require symfony/apache-pack

(I found the solution on the heroku-buildpack-php repository)

Comments

0

The best solution is to create a Procfile in the root of your repository, with the following content:

web: $(composer config bin-dir)/heroku-php-apache2 public/

Comments

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.