PHP code example of sircamp / response

1. Go to this page and download the library: Download sircamp/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/ */

    

sircamp / response example snippets


composer 

use Sircamp\Response\InfoResponse as InfoResponse;
use Sircamp\Response\WarningResponse as WarningResponse;
use Sircamp\Response\SuccessResponse as SuccessResponse;
use Sircamp\Response\DangerResponse as DangerResponse;


$data = [
    'object' => new Object('example'),
    'number' => 1,
    'string' => "hello world"
    //etc
];

$message = "I want to say hello world";

$infoResponse = new InfoResponse($data,$message);


$infoResponse->getType();


$infoResponse->setType($type);


$infoResponse->getMessage();

$message = "I want to say hello world";
$infoResponse->setMessage($message);


$infoResponse->getData();

$data = [
    'object' => new Object('example'),
    'number' => 1,
    'string' => "hello world"
    //etc
];
$infoResponse->setData($data);

$type = "custom";
BaseResponse::addAllowedType($type);