1. Go to this page and download the library: Download yeab/laravel-api-contract 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/ */
yeab / laravel-api-contract example snippets
// routes/api.php
Route::post('/users', [UserController::class, 'store'])->name('users.store');
// app/Http/Controllers/UserController.php
public function store(StoreUserRequest $request)
{
$user = User::create($request->validated());
return new UserResource($user);
}
// app/Http/Requests/StoreUserRequest.php
public function rules()
{
return [
'name' => ['