phpdocx CLI command
phpdocx CLI command
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.
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:
The available options are the following:.
Supported methods in documents generated from scratch:
- backgroundColor
- backgroundImage
- bibliography
- bookmark
- break
- chart
- citation
- comment
- cross-reference
- date
- embedFont
- 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
- merge
- sign
- stream
- tracking
- transform
- watermark
To display all available methods use --view-methods:
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: