Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Last active July 14, 2019 07:33

Revisions

  1. CMCDragonkai revised this gist Nov 21, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Secrets.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <?php

    /**
    * Loads secrets into the application. If no secrets are loaded, it will close the application and announce this.
    * Loads secrets into the application. Setup secrets via $secrets[], get secrets via $_ENV['secrets'][]
    */
    class Secrets{

  2. CMCDragonkai created this gist Nov 21, 2013.
    43 changes: 43 additions & 0 deletions Secrets.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    <?php

    /**
    * Loads secrets into the application. If no secrets are loaded, it will close the application and announce this.
    */
    class Secrets{

    public static function load(){

    $secrets_path = __DIR__ . '/secrets';
    $secrets_loaded = false;

    //see if "secrets folder" exists
    if(file_exists($secrets_path) AND is_dir($secrets_path)){

    foreach(new DirectoryIterator($secrets_path) as $file){

    //ignore dots and non-php extensions and this file itself
    if($file->isDot() OR $file->getExtension() != 'php') continue;

    $secrets_loaded = true;

    include_once($file->getPathname());

    }

    }

    if($secrets_loaded){

    foreach($secrets as $key => $value){

    $_ENV['secrets'][$key] = $value;

    }

    unset($secrets);

    }

    }

    }