8000 feature #8357 Added a Troubleshooting section to the main deployment … · symfony/symfony-docs@0f7543b · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f7543b

Browse files
committed
feature #8357 Added a Troubleshooting section to the main deployment article (javiereguiluz)
This PR was squashed before being merged into the 3.3 branch (closes #8357). Discussion ---------- Added a Troubleshooting section to the main deployment article This fixes #8298. This must go to 3.3 because that's the first Symfony version affected by this issue. Commits ------- 3d6b7eb Added a help note about glob patterns 2be4c1d Minor changes 86ccbdf Added a Troubleshooting section to the main deployment article
2 parents be6f249 + 3d6b7eb commit 0f7543b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

deployment.rst

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,35 @@ Don't forget that deploying your application also involves updating any dependen
208208
(typically via Composer), migrating your database, clearing your cache and
209209
other 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+
You can use this method to perform operations with file paths relative to your
220+
project's root directory. The logic to find that project root directory is based
221+
on the location of the main ``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+
212240
.. _`Capifony`: https://github.com/everzet/capifony
213241
.. _`Capistrano`: http://capistranorb.com/
214242
.. _`sf2debpkg`: https://github.com/liip/sf2debpkg
@@ -220,3 +248,4 @@ other potential things like pushing assets to a CDN (see `Common Post-Deployment
220248
.. _`Redis`: http://redis.io/
221249
.. _`Symfony plugin`: https://github.com/capistrano/symfony/
222250
.. _`Deployer`: http://deployer.org/
251+
.. _`Git Tagging`: https://git-scm.com/book/en/v2/Git-Basics-Tagging

service_container.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ each time you ask for it.
229229
// $this is a reference to the current loader
230230
$this->registerClasses($definition, 'AppBundle\\', '../../src/AppBundle/*', '../../src/AppBundle/{Entity,Repository}');
231231
232+
.. tip::
233+
234+
The value of the ``resource`` and ``exclude`` options can be any valid
235+
`glob pattern`_.
236+
232237
Thanks to this configuration, you can automatically use any classes from the
233238
``src/AppBundle`` directory as a service, without needing to manually configure
234239
it. Later, you'll learn more about this in :ref:`service-psr4-loader`.

0 commit comments

Comments
 (0)
0