phpdocx CLI command

phpdocx CLI command

Information

phpdocx Premium licenses include a phpdocx-cli script to speed up developments and assist you in the work with phpdocx by generating sample code skeletons, checking server settings, returning information and other useful tasks.

How to use

To run phpdocx-cli.php and view all available options, execute:

If no option or valid parameter are set, the help information is displayed.

For example, the following command generates a skeleton (phpdocx-sample-skeleton.php as default) to create a new DOCX adding text, image, list, header, footer and html methods:

Available options

The available options are the following:.

Skeleton methods

Supported methods in documents generated from scratch:

  • backgroundColor
  • backgroundImage
  • bookmark
  • break
  • chart
  • citation
  • comment
  • cross-reference
  • date
  • endnote
  • externalFile
  • footnote
  • footer
  • formElement
  • header
  • heading
  • html
  • image
  • link
  • list
  • mathEquation
  • mergeField
  • ole
  • onlineVideo
  • pageNumber
  • properties
  • section
  • shape
  • simpleField
  • source
  • structuredDocumentTag
  • styleCharacter
  • styleList
  • styleParagraph
  • styleTable
  • svg
  • tab
  • table
  • tableContents
  • tableFigures
  • text
  • textBox
  • wordML

Supported methods in documents generated with a template:

  • clearBlocks
  • cloneBlock
  • deleteBlock
  • getTemplateVariables
  • modifyInputFields
  • modifyMergeFields
  • removeVariable
  • replaceBlock
  • replaceImage
  • replaceList
  • replaceTable
  • replaceText
  • setTemplateSymbol
  • tickCheckboxes

Template methods are only added to the skeleton when a DOCX template is set using "-t" parameter:

These template methods are not added to the skeleton when creating a new DOCX without a template.

Other supported methods:

  • encrypt
  • sign
  • stream
  • transform
  • watermark

To display all available methods use --view-methods:

Examples

Generate a phpdocx skeleton using header, html, list and text methods:

Generate a phpdocx skeleton using a template and replaceImage, replaceList and replaceText methods:

Generate a phpdocx skeleton and save the sample as custom-skeleton.php:

Check server settings:

View phpdocx license information: