Search code examples
phpzend-frameworksettingspreferences

Implementing settings in my APP


I would like to implement settings/preferences in my application, which is written in PHP with Kohana and Zend Framework.

Question: What is the best approach to implement settings/preferences? I don't want to put IF statemant every time something needs to be optionally run. Is there more objective kind of way? Where can I learn to do such things?


Solution

  • What is the best approach to implement settings/preferences?

    That's hard to answer that widely, there are approaches and each have their pros and cons. Normally in PHP the best approach is to implement settings within an array variable. Later on you can add complexity by adding the ArrayAccess interface to it, convert the variable into a class or even a full facade of classes.

    I don't want to put IF statemant every time something needs to be optionally run. Is there more objective kind of way?

    If it is something conditionally, there must be a condition. Even if is pretty often used for that, you can just write expressions instead quite often:

    if ($true) do_the_thing();
    
    $true && do_the_thing();
    

    You should know the basics of the language and know about operator order to properly write expressions.

    When can I learn to do such things?

    Start now ;)