PHP code example of 3bg-supply-co / php-functions

1. Go to this page and download the library: Download 3bg-supply-co/php-functions 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/ */

    

3bg-supply-co / php-functions example snippets


  use Common3BG\ApiResponse as ApiResponse;


use Common3BG\ApiResponse as ApiResponse;

$apiResponse = new ApiResponse();

// Sample #1: simple one liner being added to message then returning the response
$apiResponse->addMessage('Testing a custom message');
$apiResponse->sendResponse();

// Sample #2: adding another message then returning the response
$apiResponse->addMessage('Testing a second custom message');
$apiResponse->sendResponse();

// Sample #3: sending a fail response without any parameters
$apiResponse->sendFailResponse();


// Sample #4: adding a string error message with no data, then returning the fail response
$apiResponse->sendFailResponse('Custom Error Message with no $data given');

// Sample $5: adding an error message with data to the errors, then returning the fail response
$apiResponse->sendFailResponse(['message' => 'Original error message from $data', 'test' => 'Some error sample here (test key is not needed)']);
$apiResponse->sendFailResponse();

// Sample #6: adding multiple errors to the errors, then returning the fail response
$apiResponse->addError(['message' => 'Custom Error Message #2', 'test' => 'Sample Error #2']);
$apiResponse->addError(['message' => 'Custom Error Message #3', 'test' => 'Sample Error #3']);
$apiResponse->sendFailResponse();
/var/www/credentials/credentials.ini
src/GenericFunctions.php