'Command composer require symfony/apache-pack doesn't create .htaccess file

When I execute the command:

composer require symfony/apache-pack

It doesn't create an .htaccess file as it is cited in the documentation here.

How can I fix this problem ?



Solution 1:[1]

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 .htaccess file. You must first remove apache pack.

So, first run composer remove symfony/apache-pack

And then run composer require symfony/apache-pack

As explained here : https://github.com/symfony/recipes-contrib/issues/676#issuecomment-519959252

Solution 2:[2]

The solution is :

1-removing symfony/apach-pack from required in compoer.json 2- run command

composer update

which delete apach-pack from project.

3-run again the command for installing apach-pack as cited in the documentation here:

composer require symfony/apache-pack

4- when asked this question :

Do you want to execute this recipe?

type :

Yes

5- That's it now the file .htaccess exists

Solution 3:[3]

I was having the same issue as Dan where composer was not asking me to execute any recipes. it turns out I needed to install Symfony Flex which wasn't present in my microkernel application. I used "composer req symfony/flex" to install it and then afterwards a remove/require of symfony/apache-pack asked me to run the recipe. You can also type "composer recipes" to see your recipes and their status, once flex is installed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 hafida Bo
Solution 3 Professor Falken