1. Go to this page and download the library: Download jongoly/api-standardizer 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/ */
namespace App\Http\Controller;
use App\Models\User;
use Jongoly\ApiStandardizer\Concerns\ApiResponse;
class UserController extends Controller
{
use ApiResponse;
public function index()
{
\$users = User::paginate(10);
// Return a standardized success response
return this->success(users, 'Users fetched successfully.', 200);
}
}