PHP code example of twom / laravel-responder

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

    

twom / laravel-responder example snippets


'providers' => [
	 // for laravel 5.8 and below
	 \Twom\Responder\ResponderServiceProvider::class,
];

use Twom\Responder\Facade\Responder; // use of this

return Responder::respond();

return Responder::respond([  
  "status" => "my status",  
  "status_code"=> 300,  
  "message" => "custom message",  
]);

return Responder::respondValidationError([  
  'title' => [  
	  'the title field is 

return Responder::respondCreated();
//	or  
return Responder::respondCreated("the created object");

return Responder::respondBadRequest();

return Responder::setMessage("test message")  
	 ->setRespondData(["the data"])  
	 ->setRespondError(["title"=> ["errors"]])  
	 ->setStatusCode(203)  
	 ->respond();