diff --git a/deployment.rst b/deployment.rst index 94dac93ba52..cda57c0d189 100644 --- a/deployment.rst +++ b/deployment.rst @@ -208,7 +208,35 @@ 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. +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. +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 +248,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 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)