Standard API Response

Submitted by saeedvir - 4 years ago

Standard API Response in PHP / Laravel

download :
  https://gist.github.com/saeedvir/4287f1ea5db2fb5eb6530fb95bdb8d0d
  
  @usage :
  
    $api_response = new ApiDataResponse;
 
       $apiResponse->setLogger(true,function($json_data,$time_stamp){
        file_put_contents('log.txt', var_export($json_data, true)."\r\n".$time_stamp."\r\n" , FILE_APPEND);
        });
        $data = ['user'=>['username','email@domain.com']]
        return $apiResponse->response(200,'data_success',$data);
        return $apiResponse->success('data_success',$data);