Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6534177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:13:10+00:00 2026-05-25T10:13:10+00:00

I want to make a local config file, config_local.yml , that allows each development

  • 0

I want to make a local config file, config_local.yml, that allows each development environment to be configured correctly without screwing up other people’s dev environments. I want it to be a separate file so that I can “gitignore” it and know that nothing essential is missing from the project, while simultaneously not having the issue of git constantly telling me that config_dev.yml has new changes (and running the risk of someone committing those changes).

Right now, I have config_dev.yml doing

imports:
    - { resource: config_local.yml }

which is great, unless the file doesn’t exist (i.e. for a new clone of the repository).

My question is: Is there any way to make this include optional? I.e., If the file exists then import it, otherwise ignore it.

Edit: I was hoping for a syntax like:

imports:
    - { resource: config.yml }
    ? { resource: config_local.yml }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:13:11+00:00Added an answer on May 25, 2026 at 10:13 am

    A solution is to create a separate environment, which is explained in the Symfony2 cookbook. If you do not wish to create one, there is another way involving the creation of an extension.

    // src/Acme/Bundle/AcmeDemo/DepencendyInjection/AcmeDemoExtension.php
    namespace Acme\DemoBundle\DependencyInjection;
    
    use Symfony\Component\Config\FileLocator;
    use Symfony\Component\DependencyInjection\ContainerBuilder;
    use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
    use Symfony\Component\HttpKernel\DependencyInjection\Extension;
    
    class AcmeDemoExtension extends Extension
    {
        public function load(array $configs, ContainerBuilder $container)
        {   
            // All following files will be loaded from the configuration directory
            // of your bundle. You may change the location to /app/ of course.
            $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
    
            try
            {
                $loader->load('config_local.yml');
            }
            catch(\InvalidArgumentException $e)
            {
                // File was not found
            }
        }
    }
    

    Some digging in the Symfony code revealed me that YamlFileLoader::load() FileLocator::locate() will throw \InvalidArgumentException, if a file is not found. It is invoked by YamlFileLoader::load().

    If you use the naming conventions, the extension will be automatically executed. For a more thorough explanation, visit this blog.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make sure my local is matching the production environment closely and
we want to make a file cache for local internet provider (like squid). Is
I want to make an etag that matches what Apache produces. How does apache
I want to make a table in SqlServer that will add, on insert, a
I want to make an entity that has an autogenerated primary key, but also
I want to store my local modifications to JBoss config in git. For this,
I want to make a list of file download links to files in my
Hey Guys I'm new to command line I want make the local changes to
my make file: all: hPif clean hPif : src/main.o src/fann_utils.o src/hashes.o src/Config.o g++ src/Config.o
It seem Mono ignores dllmaps in the local configuration file. I want to port

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.