@@ -208,7 +208,36 @@ Don't forget that deploying your application also involves updating any dependen
208208(typically via Composer), migrating your database, clearing your cache and
209209other potential things like pushing assets to a CDN (see `Common Post-Deployment Tasks `_).
210210
211- .. _`Git Tagging` : https://git-scm.com/book/en/v2/Git-Basics-Tagging
211+ Troubleshooting
212+ ---------------
213+
214+ Deployments not Using the ``composer.json `` File
215+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
216+
217+ Symfony applications provide a ``kernel.project_dir `` parameter and a related
218+ :method: `Symfony\\ Component\\ HttpKernel\\ Kernel\\ Kernel::getProjectDir> ` method
219+ so you can perform file operations relative to your project's root directory.
220+ The logic to find that directory is based on the location of the
221+ ``composer.json `` file.
222+
223+ If your deployment method doesn't use Composer, you may have removed the
224+ ``composer.json `` file and the application won't work on the production server.
225+ The solution is to override the ``getProjectDir() `` method in the application
226+ kernel and return your project's root directory::
227+
228+ // app/AppKernel.php
229+ // ...
230+ class AppKernel extends Kernel
231+ {
232+ // ...
233+
234+ public function getProjectDir()
235+ {
236+ return __DIR__.'/..';
237+ }
238+ }
239+
240+
212241.. _`Capifony` : https://github.com/everzet/capifony
213242.. _`Capistrano` : http://capistranorb.com/
214243.. _`sf2debpkg` : https://github.com/liip/sf2debpkg
@@ -220,3 +249,4 @@ other potential things like pushing assets to a CDN (see `Common Post-Deployment
220249.. _`Redis` : http://redis.io/
221250.. _`Symfony plugin` : https://github.com/capistrano/symfony/
222251.. _`Deployer` : http://deployer.org/
252+ .. _`Git Tagging` : https://git-scm.com/book/en/v2/Git-Basics-Tagging
0 commit comments