PHP code example of pulli / pullbox

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

    

pulli / pullbox example snippets


use Pulli\Pullbox\Dialog;

// Simple dialog with OK button
$result = Dialog::display('Are you sure?', 'Confirmation');

// Dialog with custom buttons, default and cancel
$result = Dialog::display('Save changes?', 'Save', [
    'buttons' => ['Save', 'Discard', 'Cancel'],
    'defaultButton' => 'Save',
    'cancelButton' => 'Cancel',
]);

// Buttons referenced by position (1-indexed)
$result = Dialog::display('Continue?', 'Confirm', [
    'buttons' => ['Yes', 'No'],
    'defaultButton' => 1,
    'cancelButton' => 2,
]);

// Dialog with text input
$result = Dialog::display('Enter your name:', 'Input', [
    'answer' => true,
]);

// Pre-filled text input
$result = Dialog::display('Rename:', 'Edit', [
    'answer' => 'current name',
]);

// Password input (hidden)
$result = Dialog::display('Password:', 'Auth', [
    'answer' => true,
    'hiddenAnswer' => true,
]);

// With icon (stop, caution, or note)
$result = Dialog::display('Are you sure?', 'Warning', [
    'icon' => 'caution',
]);

// Auto-dismiss after N seconds
$result = Dialog::display('Closing soon...', 'Notice', [
    'givingUpAfter' => 10,
]);

use Pulli\Pullbox\Notification;

// Simple notification
Notification::display('Download complete');

// With title
Notification::display('Download complete', 'My App');

// With subtitle
Notification::display('Download complete', 'My App', 'All files processed');

// With sound
Notification::display('Download complete', 'My App', null, 'Glass');

// All parameters
Notification::display('Download complete', 'My App', 'All files processed', 'Frog');

use Pulli\Pullbox\System;

// Get the Applications folder path
$path = System::applicationsFolder(); // e.g. "/Applications/"

// Move an app to Applications (quits it first, then relaunches)
System::moveApp('MyApp', '/tmp/MyApp.app');

// Move without relaunching
System::moveApp('MyApp', '/tmp/MyApp.app', launch: false);

// Get app version number
$version = System::versionNumber('Safari');
$version = System::versionNumber('Safari', 'CFBundleShortVersionString');

// Suppress error dialogs
$version = System::versionNumber('Safari', displayExceptions: false);

use Pulli\Pullbox\Music;
use Pulli\Pullbox\Enums\SystemSound;

// Export a playlist
Music::exportPlaylist('My Playlist', '/path/to/export.xml');
Music::exportPlaylist('My Playlist', '/path/to/export.m3u', 'm3u');

// Play a system sound
Music::playSystemSound(SystemSound::Glass);
Music::playSystemSound(SystemSound::Ping);

use Pulli\Pullbox\DEVONthink;
use Pulli\Pullbox\Enums\RecordType;
use Pulli\Pullbox\Enums\UpdateMode;
use Pulli\Pullbox\Enums\SummaryType;

// Create a record
$uuid = DEVONthink::createRecordWith([
    'name' => 'My Note',
    'type' => RecordType::Markdown,
    'content' => '# Hello World',
]);

// Create in a specific group
$uuid = DEVONthink::createRecordWith(
    ['name' => 'Note', 'type' => RecordType::Text, 'content' => 'Hello'],
    $groupUuid
);

// Search
$uuids = DEVONthink::search('kind:markdown name:report');

// Import, index, export
$uuid = DEVONthink::importPath('/path/to/file.pdf', $groupUuid);
$uuid = DEVONthink::indexPath('/path/to/folder', $groupUuid);
DEVONthink::export($uuid, '/path/to/export');

// Web capture
$uuid = DEVONthink::createMarkdownFrom('https://example.com');
$uuid = DEVONthink::createPdfDocumentFrom('https://example.com');
$uuid = DEVONthink::downloadUrl('https://example.com/file.zip');

// Record operations
DEVONthink::move($uuid, $targetGroupUuid);
DEVONthink::duplicate($uuid);
DEVONthink::replicate($uuid, $targetGroupUuid);
DEVONthink::delete($uuid);

// Content access
$text = DEVONthink::getTextOf($uuid);
$path = DEVONthink::pathToRecord($uuid);
$contents = DEVONthink::getRecordContents($uuid);
DEVONthink::savePlainTextToRecord('Updated text', $uuid);
DEVONthink::update($uuid, 'Appended text', UpdateMode::Appending);

// Custom metadata
DEVONthink::addCustomMetaData('value', 'myKey', $uuid);
$value = DEVONthink::getCustomMetaData('myKey', $uuid);

// Database operations
$dbName = DEVONthink::createDatabase('/path/to/new.dtBase2');
$dbName = DEVONthink::openDatabase('/path/to/existing.dtBase2');
DEVONthink::optimize('My Database');
$errors = DEVONthink::verify('My Database');

// AI & Chat (DEVONthink 4 only)
$response = DEVONthink::getChatResponseForMessage('Summarize this', engine: 'openai');
$transcript = DEVONthink::transcribe($audioUuid, language: 'en');
$summaryUuid = DEVONthink::summarizeAnnotationsOf($uuids, SummaryType::Markdown);

use Pulli\Pullbox\AppleScript;

// Execute a script (fire and forget)
AppleScript::execute($script);

// Execute and capture output
$result = AppleScript::executeAndCapture($script);

// Escape user input for safe AppleScript string interpolation
$safe = AppleScript::escapeString('He said "hello"');

// Generate script strings
$script = AppleScript::displayDialog('Hello', 'Title');
$script = AppleScript::displayNotification('Done', 'App', 'Subtitle', 'Glass');
$script = AppleScript::applicationsFolder();
$script = AppleScript::moveApp('MyApp', '/path/to/app');
$script = AppleScript::musicExportPlaylist('Playlist', '/path/to/file', 'xml');
$script = AppleScript::devonthinkPathToRecord('uuid');
$scripts = AppleScript::devonthinkImportRecords(['/path/to/file']);
$script = AppleScript::devonthinkSavePlainTextToRecord('text', 'uuid');

use Pulli\Pullbox\Enums\RecordType;

RecordType::Bookmark;       // 'bookmark'
RecordType::Feed;           // 'feed'
RecordType::FormattedNote;  // 'formatted note'
RecordType::Group;          // 'group'
RecordType::HTML;           // 'html'
RecordType::Markdown;       // 'markdown'
RecordType::Picture;        // 'picture'
RecordType::Plist;          // 'plist'
RecordType::Quicktime;      // 'quicktime'
RecordType::RTF;            // 'rtf'
RecordType::RTFD;           // 'rtfd'
RecordType::Script;         // 'script'
RecordType::Sheet;          // 'sheet'
RecordType::SmartGroup;     // 'smart group'
RecordType::Text;           // 'txt'
RecordType::WebArchive;     // 'web archive'
RecordType::Unknown;        // 'unknown'

use Pulli\Pullbox\Enums\UpdateMode;

UpdateMode::Appending;   // 'appending'
UpdateMode::Inserting;   // 'inserting'
UpdateMode::Replacing;   // 'replacing'

use Pulli\Pullbox\Enums\SummaryType;

SummaryType::Markdown;  // 'markdown'
SummaryType::Rich;      // 'rich'
SummaryType::Sheet;     // 'sheet'
SummaryType::Simple;    // 'simple'

use Pulli\Pullbox\Enums\PlaylistExportFormat;

// Available formats
PlaylistExportFormat::M3U;         // 'M3U'
PlaylistExportFormat::M3U8;        // 'M3U8'
PlaylistExportFormat::PlainText;   // 'plain text'
PlaylistExportFormat::UnicodeText; // 'Unicode text'
PlaylistExportFormat::XML;         // 'XML'

// Resolve from string
$format = PlaylistExportFormat::fromInput('m3u');  // PlaylistExportFormat::M3U

use Pulli\Pullbox\Enums\SystemSound;

// Available sounds
SystemSound::Basso;
SystemSound::Blow;
SystemSound::Bottle;
SystemSound::Frog;
SystemSound::Funk;
SystemSound::Glass;
SystemSound::Hero;
SystemSound::Morse;
SystemSound::Ping;
SystemSound::Pop;
SystemSound::Purr;
SystemSound::Sosumi;
SystemSound::Submarine;
SystemSound::Tink;

// Get the file path of a sound
$path = SystemSound::Glass->filepath(); // /System/Library/Sounds/Glass.aiff