public function configure()
    {
        if (!file_exists($this->file) || !is_readable($this->file)) {
            throw new RuntimeException(sprintf('The file "%s" does not exists or is not readable.', $this->file));
        }

        try {
            $parser = new Parser();
            $config = $parser->parse(file_get_contents($this->file));
        } catch (ParseException $exception) {
            throw new RuntimeException(sprintf('Error parsing the file "%s".', $this->file));
        }

        if (array_key_exists('magephp', $config) && is_array($config['magephp'])) {
            $logger = null;
            if (array_key_exists('log_dir', $config['magephp']) && file_exists($config['magephp']['log_dir']) && is_dir($config['magephp']['log_dir'])) {
                $logfile = sprintf('%s/%s.log', $config['magephp']['log_dir'], date('Ymd_His'));
                $config['magephp']['log_file'] = $logfile;

                $logger = new Logger('magephp');
                $logger->pushHandler(new StreamHandler($logfile));

            } elseif (array_key_exists('log_dir', $config['magephp']) && !is_dir($config['magephp']['log_dir'])) {
                throw new RuntimeException(sprintf('The configured log_dir "%s" does not exists or is not a directory.', $config['magephp']['log_dir']));
            }

            $this->runtime->setConfiguration($config['magephp']);
            $this->runtime->setLogger($logger);
            return;
        }

        throw new RuntimeException(sprintf('The file "%s" does not have a valid Magallanes configuration.', $this->file));
    }
public function configure()
    {
        if (!file_exists($this->file) || !is_readable($this->file)) {
            throw new RuntimeException(sprintf('The file "%s" does not exists or is not readable.', $this->file));
        }

        try {
            $parser = new Parser();
            $config = $parser->parse(file_get_contents($this->file));
        } catch (ParseException $exception) {
            throw new RuntimeException(sprintf('Error parsing the file "%s".', $this->file));
        }

        if (array_key_exists('magephp', $config) && is_array($config['magephp'])) {
            $logger = null;
            if (array_key_exists('log_dir', $config['magephp']) && file_exists($config['magephp']['log_dir']) && is_dir($config['magephp']['log_dir'])) {
                $logfile = sprintf('%s/%s.log', $config['magephp']['log_dir'], date('Ymd_His'));
                $config['magephp']['log_file'] = $logfile;

                $logger = new Logger('magephp');
                $logger->pushHandler(new StreamHandler($logfile));

            } elseif (array_key_exists('log_dir', $config['magephp']) && !is_dir($config['magephp']['log_dir'])) {
                throw new RuntimeException(sprintf('The configured log_dir "%s" does not exists or is not a directory.', $config['magephp']['log_dir']));
            }

            $this->runtime->setConfiguration($config['magephp']);
            $this->runtime->setLogger($logger);
            return;
        }

        throw new RuntimeException(sprintf('The file "%s" does not have a valid Magallanes configuration.', $this->file));
    }
public function configure ( ) { if ( ! file_exists ( $ this -> file ) || ! is_readable ( $ this -> file ) ) { throw new RuntimeException ( sprintf ( 'The file "%s" does not exists or is not readable.' , $ this -> file ) ) ; } try { $ parser = new Parser ( ) ; $ config = $ parser -> parse ( file_get_contents ( $ this -> file ) ) ; } catch ( ParseException $ exception ) { throw new RuntimeException ( sprintf ( 'Error parsing the file "%s".' , $ this -> file ) ) ; } if ( array_key_exists ( 'magephp' , $ config ) && is_array ( $ config [ 'magephp' ] ) ) { $ logger = null ; if ( array_key_exists ( 'log_dir' , $ config [ 'magephp' ] ) && file_exists ( $ config [ 'magephp' ] [ 'log_dir' ] ) && is_dir ( $ config [ 'magephp' ] [ 'log_dir' ] ) ) { $ logfile = sprintf ( '%s/%s.log' , $ config [ 'magephp' ] [ 'log_dir' ] , date ( 'Ymd_His' ) ) ; $ config [ 'magephp' ] [ 'log_file' ] = $ logfile ; $ logger = new Logger ( 'magephp' ) ; $ logger -> pushHandler ( new StreamHandler ( $ logfile ) ) ; } elseif ( array_key_exists ( 'log_dir' , $ config [ 'magephp' ] ) && ! is_dir ( $ config [ 'magephp' ] [ 'log_dir' ] ) ) { throw new RuntimeException ( sprintf ( 'The configured log_dir "%s" does not exists or is not a directory.' , $ config [ 'magephp' ] [ 'log_dir' ] ) ) ; } $ this -> runtime -> setConfiguration ( $ config [ 'magephp' ] ) ; $ this -> runtime -> setLogger ( $ logger ) ; return ; } throw new RuntimeException ( sprintf ( 'The file "%s" does not have a valid Magallanes configuration.' , $ this -> file ) ) ; }
Configure the Magallanes Application

@throws RuntimeException
Configure the Magallanes Application