In addition to the main reasons mentioned in other answers: incorrect server configuration, principle of least privileges, etc. - It is worth noting that many frameworks, including the Zend Framework, can use configuration files that are in formats other than PHP, for example, .ini , .yml , etc.
If they were in a public web root, then - depending on the server configuration - they will be served directly to everyone who requests them. Since these configuration files usually contain confidential information such as db passwords, API keys, etc., of course, it is advisable to make them inaccessible as inaccessible.
As an example, consider application/configs/application.ini . If the doc root was at the project folder level, then the request for:
http://example.com/application/configs/application.ini
will deliver the keys to the lock.
source share