[Bug ?] - install symfony/apache-pack does not create .htaccess file
tdimnet opened this issue · comments
Hello there,
I am working on a Symfony 4 application and I am deploying this project to Heroku.
Everything seems to work fine on local but on the dev server, only the route "/" is accessible. The other routes I created give me 404. After looking at the internet I saw it can be because of my Apache Heroku configuration.
The documentation tells me I need to install this package https://symfony.com/doc/current/setup/web_server_configuration.html and it will create a .htaccess into my public directory and it seems that no file is created.
For your information, I am using a Symfony 4.3 version with the buidpack heroku/php and my Procfile is this one: web $(composer config bin-dir)/heroku-php-apache2 public/
I think I am closed to find out what's wrong but it would be great to have your help
Do you use Symfony Flex? When you execute:
$ composer req apache-pack
It will install the recipe, so your output should be like:
Using version ^1.0 for symfony/apache-pack
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.3.*"
Package operations: 1 install, 0 updates, 0 removals
- Installing symfony/apache-pack (v1.0.1): Loading from cache
Writing lock file
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 1 recipe (a64227582fa73a4c27f76f1b6d812770)
- Configuring symfony/apache-pack (>=1.0): From github.com/symfony/recipes-contrib:master
Executing script cache:clear [OK]
Executing script assets:install --symlink --relative public [OK]
Executing script security-checker security:check [OK]
Some files may have been created or updated to configure your new packages.
Please review, edit and commit them: these files are yours.
Where:
Symfony operations: 1 recipe (a64227582fa73a4c27f76f1b6d812770)
- Configuring symfony/apache-pack (>=1.0): From github.com/symfony/recipes-contrib:master
means that the recipe was installed. Then you will find .htaccess
in public/
- you need to commit it to the repo.
Btw, did you allow installing recipes from symfony/recipes-contrib
repo?
Removing and installing the package may help you:
$ composer rem apache-pack
$ composer req apache-pack
Check the output
@bocharsky-bw : sorry for the delay, I did not take the time to answer you last week.
After a couple of research on the Internet I decided to create my own .htaccess
file with some basic rules within my public
folder.
According to your answer what I did was a basic composer install symfony/apache-pack
(or something like this, I did not manage to retrieve my command inside my command history).
Anyway this is a strange issue and hopefully it works when creating my own .htaccess
Thank you for your time and for answer.
By the way when looking at the Symfony documentation on deploying an app on Heroku I did not find a lot of documentation on the subject (and the Heroku's guide is sticked to the version 3.*).
Do you need help for updating the Symfony documentation? (I do not know if it is the right place to ask).
Hey @tdimnet, we would be happy with any help on docs! If you find something that can be improved there - please, send a PR.
However, what about deployment guide for Heroku, I think this is related to symfony/symfony-docs#8721 - looks like it was decided to do not maintain it anymore and refers to the official docs. Not sure if it's possible to send a PR to Heroku's docs, but looks like the main tweaks should be done on Heroku side.
@bocharsky-bw : Ok, great!
After looking at your link it makes sense to not update this part of the documentation. I will look at Heroku's website if is it possible to do something (I think I am not the first one who encountered this kind of issue).
Do you have any ideas where I could start or is it better to look around and find something to work on? Once again thank you for your time.
Don't have anything special on my mind. I think you can just look around and find something you might be interested in.
Cheers!
I just wanted to add that, if apache-pack is installed in your project and you later remove the .htaccess file from the /public directory, running composer require apache-pack
will not re-install the file. You must first run composer remove apache-pack
and then composer require..
again to get the recipe to run and the .htaccess file to install.
composer remove apache-pack
- composer remove apache-pack
- composer require symfony/apache-pack OR composer require apache-pack
I just wanted to add that, if apache-pack is installed in your project and you later remove the .htaccess file from the /public directory, running
composer require apache-pack
will not re-install the file. You must first runcomposer remove apache-pack
and thencomposer require..
again to get the recipe to run and the .htaccess file to install.
works for me! Tnx!
if anyone still having this, I already had executed the composer require symfony/apache-pack
command but I could not find the .htaccess file.
What I did was, executing the composer remove symfony/apache-pack
command and executing the composer require symfony/apache-pack
command again. I did this step twice until I was finally prompted to say yes for the symfony recipe and .htaccess file got generated!
If you can't see the .htaccess, after you rmv/req the package, view it in Finder/Explorer, it may be default invisible from your IDE.