1. Go to this page and download the library: Download aichadigital/bookstack-sync 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/ */
aichadigital / bookstack-sync example snippets
use AichaDigital\BookStackSync\Facades\BookStackSync;
// List all books
$books = BookStackSync::books();
// Get a specific page
$page = BookStackSync::page(123);
// Create a new page with Markdown content
$page = BookStackSync::createPage(
bookId: 5,
name: 'Configuración Inicial',
content: '# Introducción\n\nContenido aquí...',
chapterId: 10
);
// Search
$results = BookStackSync::search('instalación');
// Sync operations
$result = BookStackSync::pushToBook('/path/to/docs', 5);
$result = BookStackSync::pullFromBook(5, '/path/to/docs');
use AichaDigital\BookStackSync\Facades\BookStackSync;
// Encode for BookStack
$encoded = BookStackSync::encodeBookmark('sección-principal');
// Returns: secci%C3%B3n-principal
// Decode from BookStack
$decoded = BookStackSync::decodeBookmark('secci%C3%B3n-principal');
// Returns: sección-principal
use AichaDigital\BookStackSync\Parsers\MarkdownParser;
$parser = new MarkdownParser();
// Convert content for BookStack
$content = '# Introducción\n\nSee [sección](#sección) for details.';
$converted = $parser->parseForBookStack($content);
// Anchors are now URL-encoded
// Extract headings
$headings = $parser->extractHeadings($content);
// Generate Table of Contents
$toc = $parser->generateTableOfContents($content);
bash
# Push docs directory to book ID 5
php artisan bookstack:push docs --book=5
# Dry run (preview without changes)
php artisan bookstack:push docs --book=5 --dry-run
# Skip confirmation
php artisan bookstack:push docs --book=5 --force
bash
# Export as Markdown
php artisan bookstack:export page 123
# Export book as PDF
php artisan bookstack:export book 5 --format=pdf --output=manual.pdf
# Available formats: markdown, html, pdf, plaintext