PHP code example of webappid / smartresponse

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

    

webappid / smartresponse example snippets


use Illuminate\Http\Request;
use WebAppId\SmartResponse\Response;
use WebAppId\SmartResponse\SmartResponse;

class SampleController
{
    public function store(Request $request, SampleService $service)
    {
        $response = new ResponseDto();

        try {
            $data = $service->create($request->all());
            return $response->created('Sample created', $data);
        } catch (\Throwable $e) {
            return $response->handle($e);
        }
    }
}