PHP code example of yoanbernabeu / airtable-client-bundle

1. Go to this page and download the library: Download yoanbernabeu/airtable-client-bundle 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/ */

    

yoanbernabeu / airtable-client-bundle example snippets



use Yoanbernabeu\AirtableClientBundle\AirtableClientInterface;

class Foo
{
    public int $id;
    public string $bar;
}

class FooController
{
    public function bar(AirtableClientInterface $airtableClient)
    {
        $records = $airtableClient->findAll('tableName', 'viewName', Foo::class);
        
        foreach($records as $record) {
            /** @var Foo $foo */
            $foo = $record->getFields();
            
            echo $foo->bar;
        }
        
        $airtableClient->findBy('tableName', 'fieldName', 'value', Foo::class);      
          
        $record = $airtableClient->find('tableName', 'id');
        
        /** @var Foo $foo */
        $foo = $record->getFields();
            
        echo $foo->bar;
        
        $airtableClient->findLast('tableName', 'fieldName');

        $airtableClient->add(
            'tableName',
            [
                'id' => 1,
                'bar' => 'lorem ipsum',
                Foo::class
            ]
        );
    }

    // ...
}


use Yoanbernabeu\AirtableClientBundle\AirtableClientInterface;

class Foo
{
    public int $id;
    public string $bar;
}

class FooController
{
    public function bar(AirtableClientInterface $airtableClient)
    {
        $airtableClient->add(
            'tableName',
            [
                'id' => 1,
                'bar' => 'lorem ipsum',
                Foo::class
            ]
        );
    }

    // ...
}


use Yoanbernabeu\AirtableClientBundle\AirtableClientInterface;

class Foo
{
    public int $id;
    public string $bar;
}

class FooController
{
    public function bar(AirtableClientInterface $airtableClient)
    {
        $airtableClient->update(
            'tableName',
            'recordId',
            [
                'id' => 1,
                'bar' => 'lorem ipsum',
                Foo::class
            ]
        );
    }

    // ...
}


use Yoanbernabeu\AirtableClientBundle\AirtableClientInterface;
use Symfony\Component\HttpFoundation\Request;

class FooController
{
    public function bar(AirtableClientInterface $airtableClient, Request $request)
    {
        $form = $airtableClient->createForm([
            'Name' => TextType::class,
            'text' => TextType::class,
            'Submit' => SubmitType::class
        ]);

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $data = $form->getData();
            $airtableClient->add('test', $data);
        }
        return $this->render('bar.html.twig', [
            'form' => $form->createView()
        ]);
    }

    // ...
}


use Yoanbernabeu\AirtableClientBundle\AirtableClientInterface;

class FooController
{
    public function bar(AirtableClientInterface $airtableClient)
    {
        // Get Metadata for All Tables
        $tablesMeta = $airtableClient->getTablesMetadata();

        // Get Metadata for One Table
        $tableMeta = $airtableClient->getTableMetadata('TableName');

    // ...
}