I think in this senario I wouldn't use php, probably I would try to make a golang or java application to handle the device management and also use this apps to build the backend server & api(restful, websockets for realtime updates) with a frontend framework/ecosystem like angular, react, vuejs etc..