1. Go to this page and download the library: Download phl/laravel-respond-to 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/ */
phl / laravel-respond-to example snippets
use PHL\LaravelRespondTo\Respond;
class MyController
{
public function index()
{
return Respond::to('html')->withView('hello', ['name' => 'John Doe'])
->to('json')->with(['key' => 'value'])
->to('txt')->with('some text')
->to('xml')->with(function () {})
->to('rss')->with(new \Illuminate\Http\Response())
->to('css')->with(new ResponsableClass);
}
}
use PHL\LaravelRespondTo\Respond;
Respond::withNewRespond()
->to('json')->with(['key' => 'value'])
->default('json');