1. Go to this page and download the library: Download wmbh/laravel-fibery 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/ */
use WMBH\Fibery\Facades\Fibery;
// Basic query
$tasks = Fibery::query('Project/Task')
->select(['fibery/id', 'fibery/name', 'Project/Status'])
->where('Project/Status', 'Active')
->orderBy('fibery/creation-date', 'desc')
->limit(10)
->get();
// Get first result
$task = Fibery::query('Project/Task')
->select(['fibery/id', 'fibery/name'])
->where('fibery/public-id', 'TASK-123')
->first();
// Check existence
$exists = Fibery::query('Project/Task')
->where('fibery/name', 'My Task')
->exists();
// Count results
$count = Fibery::query('Project/Task')
->where('Project/Status', 'Active')
->count();
// Equals (shorthand)
->where('Project/Status', 'Active')
// With operator
->where('Project/Priority', '>', 5)
->where('Project/DueDate', '<=', '2024-12-31')
// Where In
->whereIn('Project/Status', ['Active', 'In Progress'])
// Where Null / Not Null
->whereNull('Project/Assignee')
->whereNotNull('Project/DueDate')
// Multiple conditions (AND)
->where('Project/Status', 'Active')
->where('Project/Priority', '>', 3)
// OR conditions
->orWhere([
['Project/Status', '=', 'Active'],
['Project/Priority', '>', 5],
])
// Include related entity fields
$tasks = Fibery::query('Project/Task')
->select(['fibery/id', 'fibery/name'])
->with('Project/Assignee', ['fibery/id', 'fibery/name', 'user/email'])
->get();
// Include collection with subquery
$tasks = Fibery::query('Project/Task')
->select(['fibery/id', 'fibery/name'])
->with('Project/Tags', function ($query) {
$query->select(['fibery/id', 'Project/name'])
->limit(5);
})
->get();
// Aggregates
$projects = Fibery::query('Project/Project')
->select(['fibery/id', 'fibery/name'])
->withCount('task_count', ['Project/Tasks', 'fibery/id'])
->get();
$tasks = Fibery::query('Project/Task')
->select(['fibery/id', 'fibery/name'])
->limit(10)
->offset(20) // Skip first 20
->get();
// Aliases
->take(10)
->skip(20)
// Get all results (use carefully)
->noLimit()
// Create - returns the created entity with its fibery/id (UUID)
$task = Fibery::create('Project/Task', [
'fibery/name' => 'New Task',
'Project/Priority' => 5,
// For relations, pass an object with fibery/id of the related entity
'Project/Status' => ['fibery/id' => '123e4567-e89b-12d3-a456-426614174000'],
]);
// $task['fibery/id'] contains the UUID of the created entity
// Update - pass the entity UUID (fibery/id), NOT the public ID
Fibery::update('Project/Task', '123e4567-e89b-12d3-a456-426614174000', [
'fibery/name' => 'Updated Task Name',
'Project/Priority' => 10,
]);
// Delete - pass the entity UUID (fibery/id)
Fibery::delete('Project/Task', '123e4567-e89b-12d3-a456-426614174000');
// Find by UUID (fibery/id) - the internal unique identifier
$task = Fibery::find('Project/Task', '123e4567-e89b-12d3-a456-426614174000');
// Find by Public ID (fibery/public-id) - the human-readable ID like "TASK-123"
$task = Fibery::findByPublicId('Project/Task', 'TASK-123');
// Create or Update (upsert) - useful for syncing external data
Fibery::entity()->createOrUpdate('Project/Task', [
'fibery/name' => 'Task Name',
'Project/ExternalId' => 'ext-123',
], ['Project/ExternalId']); // Field to check for duplicates
// All collection operations use fibery/id (UUIDs)
// Add tags to a task - pass entity UUID and array of tag UUIDs
Fibery::addToCollection(
'Project/Task', // Type name
'123e4567-e89b-12d3-a456-426614174000', // Task's fibery/id
'Project/Tags', // Collection field name
['abc-uuid-1', 'def-uuid-2'] // Tag fibery/ids to add
);
// Remove items from collection
Fibery::removeFromCollection('Project/Task', 'task-uuid', 'Project/Tags', ['tag-uuid-1']);
// Replace all collection items (removes existing, adds new)
Fibery::setCollection('Project/Task', 'task-uuid', 'Project/Tags', ['tag-uuid-3']);
// Clear all items from collection
Fibery::clearCollection('Project/Task', 'task-uuid', 'Project/Tags');
// Get full schema
$schema = Fibery::schema()->getSchema();
// Get all types (databases)
$types = Fibery::schema()->getTypes();
// Get specific type
$taskType = Fibery::schema()->getType('Project/Task');
// Get fields for a type
$fields = Fibery::schema()->getFields('Project/Task');
// Get all spaces
$spaces = Fibery::schema()->getSpaces();
// Get types in a space
$projectTypes = Fibery::schema()->getTypesInSpace('Project');
// Check if type exists
if (Fibery::schema()->typeExists('Project/Task')) {
// ...
}
// Create a new database
Fibery::types()->create('Project', 'Feature');
// Rename a database
Fibery::types()->rename('Project/Feature', 'Project/Enhancement');
// Delete a database
Fibery::types()->delete('Project/Enhancement');
// Create a webhook for a type
$webhook = Fibery::webhooks()->create('https://your-endpoint.com/webhook', 'Space/Task');
// Returns: ['id' => 5, 'url' => '...', 'type' => 'Space/Task', 'state' => 'active', ...]
// List all webhooks
$webhooks = Fibery::webhooks()->all();
// Get a webhook by ID
$webhook = Fibery::webhooks()->get(5);
// Delete a webhook
Fibery::webhooks()->delete(5);
// Get webhooks filtered by type
$webhooks = Fibery::webhooks()->getByType('Space/Task');
// Check if a webhook exists
if (Fibery::webhooks()->exists(5)) {
// ...
}