PHP code example of stevecomrie / baserow-php

1. Go to this page and download the library: Download stevecomrie/baserow-php 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/ */

    

stevecomrie / baserow-php example snippets






use \Scomrie\Baserow\Baserow;

$baserow = new Baserow([
    'api_key' => 'API_KEY', // REQUIRED!!

    // if you are self hosting your own instance of Baserow, use this parameter to
    // point to the proper location on your server. defaults to the SaaS hosted endpoint.
    'api_url' => 'https://api.baserow.io/api/database/rows/table'

    // if set to true, will dump any errors with print_r() and exit on failure
    'debug' => false,

    // map of all tables & fields from auto-generated ###'s to human readable names
    'table_map' => []
]);

$response = $baserow->list( 'Contacts' );

print_r($response);

$params = array(
    "page" => 1,
    "size" => 100,
    "order_by" => "lastName",
    "filter__firstName__equal" => "Steve",
    "

$response = $baserow->all( 'Contacts', $params );
print_r($response);

$newContact = [
	'firstName' => "Steve",
	'lastName'  => "Comrie",
	'active'    => true,
	'projects'  => [ 2 ],
];

if( $contact = $baserow->create( "Contacts", $newContact ) ) {
	echo "Created new contact: " . $contact->id . "\n";
} else {
	print_r( $baserow->error() );
}

$contactID = 1;
$updatedFields = [
	'firstName' => "Steven",
	'active'    => false,
];

if( $baserow->update( "Contacts", $updatedFields, $contactID ) ) {
	echo "Contact updated!\n";
}

$deleteContactID = 4;
if( $baserow->delete("Contacts", $deleteContactID ) ) {
	echo "Contact deleted!\n";
}

$error = $baserow->error();
print_r( $error );