PHP code example of survos / bookmark-bundle

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

    

survos / bookmark-bundle example snippets


use Doctrine\ORM\Mapping as ORM;
use Survos\BookmarkBundle as Bookmarks;

// App\Entity\Bookmark
#[ORM\Entity(repositoryClass: Bookmarks\Repository\BookmarkRepository::class)]
#[ORM\Table(name: 'bookmark')]
#[ORM\UniqueConstraint(name: 'uniq_bookmark_row', fields: ['user', 'provider', 'dataset', 'coreCode', 'localId'])]
class Bookmark extends Bookmarks\Entity\Bookmark
{
    #[ORM\Column(nullable: true)]
    public ?string $annotation = null;
}

// App\Entity\Folder
#[ORM\Entity(repositoryClass: Bookmarks\Repository\FolderRepository::class)]
#[ORM\Table(name: 'folder')]
#[ORM\UniqueConstraint(name: 'uniq_folder_user_slug', fields: ['user', 'slug'])]
class Folder extends Bookmarks\Entity\Folder {}

$target = new TargetReference(
    source: 'pressia.example', // stable provider/site namespace; use the same value on every peer
    class: 'Article',        // vocabulary term, never dynamically instantiated
    identifier: '42',
    collection: 'external', // default; use a stable dataset name when applicable
);
$bookmark = $manager->save($user, $target, label: 'An article');

$snapshot = new BookmarkSnapshot($target, 'https://pressia.example/articles/42',
    label: 'An article', notes: 'Why I saved it', tags: ['history'],
    origin: 'https://pressia.example/bookmarks/123');
$bookmark = $manager->receive($authenticatedUser, $snapshot);