PHP code example of eloquage / laravel-wayfinder-forge

1. Go to this page and download the library: Download eloquage/laravel-wayfinder-forge 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/ */

    

eloquage / laravel-wayfinder-forge example snippets


return [
    /**
     * The output path for the generated TypeScript SDK file.
     */
    'output_path' => resource_path('js/api/sdk.ts'),

    /**
     * Define which routes should be processed.
     */
    'routes' => [
        // Only he HTTP client template to use for the generated SDK.
     * Supported: 'axios', 'fetch', 'inertia'
     */
    'client' => 'axios',

    /**
     * Enable support for spatie/laravel-data objects.
     */
    'use_spatie_data' => true,
];

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StorePostRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'title' => 'PostController::class, 'store'])->name('posts.store');

namespace App\Data;

use Spatie\LaravelData\Data;

class UserData extends Data
{
    public string $name;
    public ?int $age;
}

// routes/api.php
Route::post('api/users', function (UserData $userData) { 
    // ...
});
bash
php artisan vendor:publish --tag=wayfinder-forge-config
bash
php artisan wayfinder:forge