You can use this service to get distance between two coordinates in KM in php
Example
$lagos= ['longitude'=>'3.379206','latitude'=>'6.524379'];
$dublin= ['longitude'=>'-6.260310','latitude'=>'53.349804'];
GeoFenceService::getDistanceBetweenCoordinatesInKm($lagos,$dublin);