src/abstracts/Component.php
public static function getInstance($configs = null)
    {
        if (null === $configs) {
            throw new Exception('组件实例化参数为空', 100300101);
        }
        if (is_string($configs)) {
            $configs = Config::getInstance($configs)->getAll();
        } else if (!is_array($configs)) {
            throw new Exception('组件实例化参数错误', 100300102);
        } else if (isset($configs['c-file'])) {
            if (isset($configs['c-group']) && !empty($configs['c-group'])) {
                $configs = Config::getInstance($configs['c-file'], $configs['c-group'])->getAll();
            } else {
                $configs = Config::getInstance($configs['c-file'])->getAll();
            }
        }

        $className = get_called_class();
        $id = md5($className . serialize($configs));
        if (!isset(self::$_instances[$id])) {
            if (!is_array($configs)) {
                throw new Exception('组件实例化时参数必须为数组', 100300103);
            }
            $instance = new $className($configs);
            if (!$instance instanceof Component) {
                throw new Exception('组件必须继承基类"\Abstracts\Component"', 100300104);
            }
            $instance->init();
            self::$_instances[$id] = $instance;
        }
        return self::$_instances[$id];
    }
public static function getInstance($configs = null)
    {
        if (null === $configs) {
            throw new Exception('组件实例化参数为空', 100300101);
        }
        if (is_string($configs)) {
            $configs = Config::getInstance($configs)->getAll();
        } else if (!is_array($configs)) {
            throw new Exception('组件实例化参数错误', 100300102);
        } else if (isset($configs['c-file'])) {
            if (isset($configs['c-group']) && !empty($configs['c-group'])) {
                $configs = Config::getInstance($configs['c-file'], $configs['c-group'])->getAll();
            } else {
                $configs = Config::getInstance($configs['c-file'])->getAll();
            }
        }

        $className = get_called_class();
        $id = md5($className . serialize($configs));
        if (!isset(self::$_instances[$id])) {
            if (!is_array($configs)) {
                throw new Exception('组件实例化时参数必须为数组', 100300103);
            }
            $instance = new $className($configs);
            if (!$instance instanceof Component) {
                throw new Exception('组件必须继承基类"\Abstracts\Component"', 100300104);
            }
            $instance->init();
            self::$_instances[$id] = $instance;
        }
        return self::$_instances[$id];
    }
组件实例化
@param mixed $configs
@return $this
@throws Exception