PHP code example of abdulbaset / response-format-trait
1. Go to this page and download the library: Download abdulbaset/response-format-trait 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/ */
abdulbaset / response-format-trait example snippets
use Abdulbaset\ResponseFormatTrait\Respond;
class YourController extends Controller
{
use Respond;
public function someMethod()
{
// Example usage:
return $this->formatApi(200, 'Success', 'Resource created successfully', $data);
}
}
use Abdulbaset\ResponseFormatTrait\Respond;
class YourController extends Controller
{
public function someMethod()
{
// Example usage:
return Respond::formatApi(200);
}
}
use Abdulbaset\ResponseFormatTrait\Respond;
class YourController extends Controller
{
public function someMethod()
{
if (Respond::isLanguageSupported('en')) {
// English language is supported
// Perform actions accordingly
} else {
// English language is not supported
// Handle unsupported language scenario
}
}
}