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

  • Home
  • SEARCH
  • 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 4057798
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:59:54+00:00 2026-05-20T14:59:54+00:00

I have my config defined via Zend_Config_Ini adapter, with production, development and testing sections.

  • 0

I have my config defined via Zend_Config_Ini adapter, with production, development and testing sections. In my controller I would like to take certain actions depending on what environment/section I am currently using – e.g. I only want to send email in production and testing, not in development.

Is there a way to determine which environment/section I am using the controller? I can set a value in the config and grab that in the controllers, but seems like there would be a cleaner way to determine.

  • 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-20T14:59:55+00:00Added an answer on May 20, 2026 at 2:59 pm

    If you put the code that depends on the environment in your controller, like this :

    if ($env == 'production') {
        // send mail
    }
    

    It adds logic in the controller — the sending of the mail doesn’t depend on the configuration anymore.

    I think it’s better to add one mail.enable option in your configuration files, and use that specific option in your code, to determine whether or not you must send mails.

    This way :

    • The configuration is the one which defines if mails should be sent or not
    • The day you want to send mails from your development environment, you just have to change one entry in your configuration file ; and not the code.

    Of course, it means a couple more configuration entries (one to enable/disable e-mails, one for any other thing that can be enabled or not) ; but, in the end, that’s what configuration is for.

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

Sidebar

Related Questions

I would like to have individuals config for my rails apps on my server,
I have written a service that I would like expose both via rest and
I have defined a config section in my app.config in the following way: <?xml
I have defined two endpoints in my App.Config file as <system.serviceModel> <services> <service name=HostDirectAddress.ITestService
I have a class Bar that has a user-defined list of config keys and
I have the following defined in my web.config ( <rewriteMaps configSource=Rewrites.config /> I have
I have defined a custom section in the App.config file and all the Configuration
In ASP.NET application's web.config, I have something like this <sessionState mode=InProc cookieless=false timeout=30/> Is
I have seen this problem arise in many different circumstances and would like to
I have 4 entities which I've defined Navigation properties on like the following: internal

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.