1. Go to this page and download the library: Download arpanpatoliya/response 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/ */
arpanpatoliya / response example snippets
// Basic success response
return response()->success('User created successfully', $userData);
// Error response
return response()->notFound('User not found');
// Validation error
return response()->validationFailure($validator);
// Custom status code
return response()->conflict('Resource already exists');
// Success with data (200)
return response()->success('User created successfully', $userData);
// Success message only (200)
return response()->successMessage('User updated successfully');
// Resource created (201)
return response()->created('User created successfully', $userData);
// Resource updated (200)
return response()->updated('User updated successfully', $userData);
// Resource deleted (200)
return response()->deleted('User deleted successfully');
// Accepted (202)
return response()->accepted('Request accepted for processing');
// Basic error (200)
return response()->errorMessage('User not found');
// Error with custom status code
return response()->error('Bad request', 400);
// HTTP status specific errors
return response()->badRequest('Invalid input data');
return response()->unauthorized('Invalid credentials');
return response()->forbidden('Access denied');
return response()->notFound('User not found');
return response()->conflict('Resource already exists');
return response()->tooManyRequests('Rate limit exceeded');
return response()->serverError('Database connection failed');