PHP code example of tropikal-ai / connect

1. Go to this page and download the library: Download tropikal-ai/connect 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/ */

    

tropikal-ai / connect example snippets


use TropikalAI\Connect\Domain\Resource\FieldDescriptor;
use TropikalAI\Connect\Domain\Resource\ResourceSchema;

$schema = new ResourceSchema(
    key: 'research_posts',
    label: 'Research Posts',
    identifier: 'id',
    fields: [
        new FieldDescriptor('title', 'Title', readable: true, writable: true),
        new FieldDescriptor('status', 'Status', readable: true, writable: true),
        new FieldDescriptor('published_at', 'Published at', readable: true, writable: false),
    ],
    grants: ['read', 'write'],
);

$publicRecord = $schema->project([
    'id' => 123,
    'title' => 'Example',
    'status' => 'draft',
    'internal_notes' => 'not exposed',
]);

$unknownFields = $schema->unknownWriteFields([
    'title' => 'Updated',
    'internal_notes' => 'rejected',
]);