如何做动态php命名空间

OK, Here is the actual issue broken down:

using namespacing:

 \home\Homecontroller::get(); // returns what I want

Without using namespacing:

$str = "Homecontroller@get"
$caller = explode('@', $str);
$caller[0]::$caller[1](); // returns what I want

Every attempt to do this dynamically fails

\$namespace\$caller[0]::$caller[1](); // fails
eval("\\${namespace}\\${caller[0]}::${caller[1]}()"); // fails

in the homecontroller.php file I have:

<?php
namespace home;
class Homecontroller {
    public function Homecontroller()
    {
        throw new Exception("Homecontroller is a static class");
    }
    public static function jsonify($data)
    {
        header('Cache-Control: no-cache, must-revalidate');
        header('Expires: Mon, 26 Jul 2016 05:00:00 GMT');
        header('Content-type: application/json');
        print json_encode ($data);
        exit();
    }
    public static function get()
    {
        $data = [];
        $data['message'] = "You have called the GET function";
        self::jsonify($data);
    }
}

I am building a framework that needs to respect the namespacing, but not specifically aware of them. I need to keep the namespaces listed in an external config file.

Build the fully qualified class name as a string, then call the method on it:

namespace home;
class Homecontroller {
    private function __construct()
    {}
    public static function jsonify($data)
    {
        header('Cache-Control: no-cache, must-revalidate');
        header('Expires: Mon, 26 Jul 2016 05:00:00 GMT');
        header('Content-type: application/json');
        print json_encode ($data);
        exit();
    }
    public static function get()
    {
        $data = [];
        $data['message'] = "You have called the GET function";
        self::jsonify($data);
    }
}
$namespace = "home";
$str = "Homecontroller@get";
$caller = explode('@', $str);
$cls = "\\$namespace\\$caller[0]";
$method = $caller[1];

$cls::$method();
//or use call_user_func
call_user_func([$cls, $method]);