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 6168679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:43:44+00:00 2026-05-23T22:43:44+00:00

My config/database.php file contains a simple conditional that swaps out database credentials based on

  • 0

My config/database.php file contains a simple conditional that swaps out database credentials based on the server it lives:

$server = $_SERVER['SERVER_NAME'];
if(($server=='localhost')||($server=='127.0.0.1'))
{
    $db['default']['hostname'] = 'MY_LOCAL_IP';
    $db['default']['username'] = 'MY_LOCAL_USERNAME';
    $db['default']['password'] = 'MY_LOCAL_PASSWORD';
    $db['default']['database'] = 'MY_LOCAL_DB';
}
else 
{
    $db['default']['hostname'] = 'MY_PROD_IP';
    $db['default']['username'] = 'MY_PROD_USERNAME';
    $db['default']['password'] = 'MY_PROD_PASSWORD';
    $db['default']['database'] = 'MY_PROD_DB';
}

I started playing around with Doctrine today and one thing that caught my eye was the Command Line Interface. The prompt can do all sorts of things, one of which is verification that doctrine is properly configured for production use.

But when calling ensure-production-settings in the CLI, the interface yells at me stating that SERVER_NAME is an undefined index. While this isn’t much of an issue, it got me thinking that Doctrine might be silently complaining of the same thing in the background during the execution of my application.

I guess I could make two separate database.php files – but before that – has anybody experienced issues with Doctrine CLI after making a change to config/database.php?

  • 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-23T22:43:45+00:00Added an answer on May 23, 2026 at 10:43 pm

    Well $_SERVER['SERVER_NAME'] is not set in CLI mode, since this information is provided by the CGI-interface of your webserver (or by the webserver itself when using php as a module).

    Why don’t you use environments for that?

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

Sidebar

Related Questions

I require a file in my PHP file require('config.local.php'); that contains the database credentials
I have an config.php file where I simply make an huge array that contains
i use a file ( ss-config.php ) which contains informations about servor and database
Can you help me how to use class defined in CakePHP's /config/database.php file, for
I have the following .gitignore file # file named .gitignore system/application/config/database.php system/application/config/config.php system/logs modules/recaptcha/config/*
I need to store database passwords in a config file. For obvious reasons, I
I have referenced a config file that is located in a solution folder. I
I have following in my config.php file for one of my web app. //db
What is the file, where database setting are stored in Joomla CMS? Like server,
I have created a file name database.php and here is it's content <?php #Start

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.