PHP code example of artyuum / symfony-jsend-response
1. Go to this page and download the library: Download artyuum/symfony-jsend-response 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/ */
artyuum / symfony-jsend-response example snippets
use Junker\JSendResponse\JSendResponse;
use Junker\JSendResponse\JSendSuccessResponse;
use Junker\JSendResponse\JSendFailResponse;
use Junker\JSendResponse\JSendErrorResponse;
class AppController
{
...
$data = ['id' => 50, 'name' => 'Waldemar'];
$message = 'Error, total error!';
$code = 5;
return new JSendResponse(JSendResponse::STATUS_SUCCESS, $data);
// or
return new JSendResponse(JSendResponse::STATUS_FAIL, $data);
// or
return new JSendResponse(JSendResponse::STATUS_ERROR, NULL, $message);
// or
return new JSendResponse(JSendResponse::STATUS_ERROR, $data, $message, $code);
// or
return new JSendSuccessResponse($data);
// or
return new JSendFailResponse($data);
// or
return new JSendErrorResponse($message);
// or
return new JSendErrorResponse($message, $code, $data);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.