PHP code example of vitisstudio / restdb-openapi

1. Go to this page and download the library: Download vitisstudio/restdb-openapi 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/ */

    

vitisstudio / restdb-openapi example snippets


class Post extends Model
{
    use \Vitis\RestDB\OpenApi\IsOpenApiResource;

    protected $connection = 'blog';
    protected $table = 'posts';

    public function author(): BelongsTo   { return $this->belongsTo(Author::class, 'author_id'); }
    public function comments(): HasMany    { return $this->hasMany(Comment::class, 'post_id'); }
}

final class ErpEndpoints
{
    public const MAP    = ['customer' => '/objects/order-entry/customer', …];
    public const FIELDS = ['customer' => ['id', 'name'], …];
    public const MODELS = ['customer' => \App\Models\Customer::class, …];
}
bash
php artisan restdb:make-openapi-models blog \
    --spec=openapi.json \
    --path=app/Models \
    --namespace="App\\Models"
bash
php artisan restdb:make-openapi-models erp \
    --spec=openapi.json \
    --path=app/Models --namespace="App\\Models" \
    --endpoints="App\\RestDB\\ErpEndpoints" \
    --endpoints-path=app/RestDB/ErpEndpoints.php