Tutorial Using Configs

Discussion in 'Resources' started by Jack Noordhuis, Apr 24, 2017.

  1. PiloudeDakar

    PiloudeDakar Spider Jockey

    Messages:
    25
    GitHub:
    PiloudeDakar
    Thanks a lot
     
  2. PiloudeDakar

    PiloudeDakar Spider Jockey

    Messages:
    25
    GitHub:
    PiloudeDakar
    Hey, sorry, second question : in a yaml config, how to use under cotegories :
    Code:
    category1:
      category2: value
    In this case, how to take category2's value ?
     
  3. Primus

    Primus Zombie Pigman

    Messages:
    627
    It's called nested values.
    PHP:
    Config::getNested('category1.category2');
     
    PiloudeDakar likes this.
  4. TestDevelopment

    TestDevelopment Spider Jockey

    Messages:
    37
    GitHub:
    non

    Better use this:
    PHP:
    // let's imagine there's a key in the config called join_message
    // and we search for JOIN_MESSAGE
    // if we set the second parameter to false, the exists function would return false thus the code inside the if statement won't run
    if(!$config->exists("JOIN_MESSAGE")){
        
    $this->getLogger()->info("key exists"); // it won't print "key exists" on the console
    }

    // let's try setting the second parameter to true
    if($config->exists("JOIN_MESSAGE")){
        
    $this->getLogger()->info("key exists"); // it will print "key exists" on the console
    }
     
  5. mmm545

    mmm545 Baby Zombie

    Messages:
    154
    GitHub:
    mmm545
    what? i was just explaining what the second parameter does
     
    Primus likes this.
  6. Phqzing

    Phqzing Spider

    Messages:
    8
    GitHub:
    phqzing
    How can I make it so instead if manually going to the .php file I can edit it through the config.yml?
     

    Attached Files:

  7. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,394
    GitHub:
    HimbeersaftLP
    You could try reading the post you're replying to...
     
    Primus likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.