PHP code example of dskripchenko / php-docx-phpword

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

    

dskripchenko / php-docx-phpword example snippets


use Dskripchenko\PhpDocxPhpWord\PhpWordBridge;

$html = PhpWordBridge::toHtml($phpWord);   // clean HTML, inline styles

$phpWord = PhpWordBridge::fromHtml('<h1>Report</h1><p>Body with <b>bold</b>.</p>');
// … continue with PHPWord-native calls and writers

$phpWord = PhpWordBridge::readToPhpWord(file_get_contents('from-word.docx'));

$variables = PhpWordBridge::detectVariables($phpWordOrDocxBytes);
// MERGEFIELD, SDT content controls, {{x}} / ${x} / %x% patterns
bash
composer