PHP code example of urameshibr / jsonresponse

1. Go to this page and download the library: Download urameshibr/jsonresponse library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

urameshibr / jsonresponse example snippets



// Any controller
public function show($id)
{
  $customer = $this->repository->showCustomerData($id);
  
  return $customer-isEmpty()
    ? json_response(false, 404, "Customer not found")
    : json_response(true, 200, "Customer info", $customer);
}