From 86ccbdf451d0f7c61d9d5452c86bde064d265ba4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 6 Sep 2017 17:19:58 +0200 Subject: [PATCH 1/3] Added a Troubleshooting section to the main deployment article --- deployment.rst | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/deployment.rst b/deployment.rst index 94dac93ba52..ef1308690c5 100644 --- a/deployment.rst +++ b/deployment.rst @@ -208,7 +208,36 @@ Don't forget that deploying your application also involves updating any dependen (typically via Composer), migrating your database, clearing your cache and other potential things like pushing assets to a CDN (see `Common Post-Deployment Tasks`_). -.. _`Git Tagging`: https://git-scm.com/book/en/v2/Git-Basics-Tagging +Troubleshooting +--------------- + +Deployments not Using the ``composer.json`` File +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Symfony applications provide a ``kernel.project_dir`` parameter and a related +:method:`Symfony\\Component\\HttpKernel\\Kernel\\Kernel::getProjectDir>` method +so you can perform file operations relative to your project's root directory. +The logic to find that directory is based on the location of the +``composer.json`` file. + +If your deployment method doesn't use Composer, you may have removed the +``composer.json`` file and the application won't work on the production server. +The solution is to override the ``getProjectDir()`` method in the application +kernel and return your project's root directory:: + + // app/AppKernel.php + // ... + class AppKernel extends Kernel + { + // ... + + public function getProjectDir() + { + return __DIR__.'/..'; + } + } + + .. _`Capifony`: https://github.com/everzet/capifony .. _`Capistrano`: http://capistranorb.com/ .. _`sf2debpkg`: https://github.com/liip/sf2debpkg @@ -220,3 +249,4 @@ other potential things like pushing assets to a CDN (see `Common Post-Deployment .. _`Redis`: http://redis.io/ .. _`Symfony plugin`: https://github.com/capistrano/symfony/ .. _`Deployer`: http://deployer.org/ +.. _`Git Tagging`: https://git-scm.com/book/en/v2/Git-Basics-Tagging From 2be4c1d3449411d9160f12f566c0f5afc8872a7f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 3 Oct 2017 15:34:50 +0200 Subject: [PATCH 2/3] Minor changes --- deployment.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/deployment.rst b/deployment.rst index ef1308690c5..cda57c0d189 100644 --- a/deployment.rst +++ b/deployment.rst @@ -215,10 +215,10 @@ Deployments not Using the ``composer.json`` File ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Symfony applications provide a ``kernel.project_dir`` parameter and a related -:method:`Symfony\\Component\\HttpKernel\\Kernel\\Kernel::getProjectDir>` method -so you can perform file operations relative to your project's root directory. -The logic to find that directory is based on the location of the -``composer.json`` file. +:method:`Symfony\\Component\\HttpKernel\\Kernel\\Kernel::getProjectDir>` method. +You can use this method to perform operations with file paths relative to your +project's root directory. The logic to find that project root directory is based +on the location of the main ``composer.json`` file. If your deployment method doesn't use Composer, you may have removed the ``composer.json`` file and the application won't work on the production server. @@ -237,7 +237,6 @@ kernel and return your project's root directory:: } } - .. _`Capifony`: https://github.com/everzet/capifony .. _`Capistrano`: http://capistranorb.com/ .. _`sf2debpkg`: https://github.com/liip/sf2debpkg From 3d6b7eb5ee315a936425e13204ece87b9ccefc4d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 3 Oct 2017 15:51:58 +0200 Subject: [PATCH 3/3] Added a help note about glob patterns --- service_container.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service_container.rst b/service_container.rst index 6debeb8f01b..620919da881 100644 --- a/service_container.rst +++ b/service_container.rst @@ -229,6 +229,11 @@ each time you ask for it. // $this is a reference to the current loader $this->registerClasses($definition, 'AppBundle\\', '../../src/AppBundle/*', '../../src/AppBundle/{Entity,Repository}'); + .. tip:: + + The value of the ``resource`` and ``exclude`` options can be any valid + `glob pattern`_. + Thanks to this configuration, you can automatically use any classes from the ``src/AppBundle`` directory as a service, without needing to manually configure it. Later, you'll learn more about this in :ref:`service-psr4-loader`. @@ -1043,3 +1048,4 @@ Learn more .. _`service-oriented architecture`: https://en.wikipedia.org/wiki/Service-oriented_architecture .. _`Symfony Standard Edition (version 3.3) services.yml`: https://github.com/symfony/symfony-standard/blob/3.3/app/config/services.yml +.. _`glob pattern`: https://en.wikipedia.org/wiki/Glob_(programming)