outman / xinsight-server

Backend server for php xhprof web ui XInsight

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XInsight backend server

Config

.env

cp .env.example .env
composer run start

Admin user

.env SYSTEM_USERS

xhprof extension data

// start
xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);


// register shutdown function to record xhprof result
register_shutdown_function(function() use ($request, $mongoHost, $mongoOptions) {
    try {
        $profile = xhprof_disable();
        $value = [
            'url'          => $request->getUri()->getPath(),
            'server_name'  => gethostname(),
            'request_time' => $_SERVER['REQUEST_TIME'],
            'profile'      => json_encode(['profile' => $profile]),
            'mu'           => $profile['main()']['mu'],
            'pmu'          => $profile['main()']['pmu'],
            'ct'           => $profile['main()']['ct'],
            'cpu'          => $profile['main()']['cpu'],
            'wt'           => $profile['main()']['wt'],
            'create_at'    => new \MongoDate(),
        ];
        
        // save data
        $mongo = new \MongoClient($mongoHost, $mongoOptions);
        $collection = $mongo->selectDB("xhprof")->selectCollection("xhprof");
        $collection->insert($value);
    } catch (\Throwable $e) {
        \error_log('xhprof error:' . $e->getMessage());
    }
});

About

Backend server for php xhprof web ui XInsight


Languages

Language:PHP 100.0%