Run CLI commands with RSForm!Pro

Joomla! 4 comes with a powerful application designed to carry out maintenance tasks without even logging into your website. More precisely, the Command-Line Interface, known as CLI. You can find more information on this topic here.

The new RSForm!Pro CLI System plugin is designed to interact with the Joomla! 4 cli/joomla.php script and allows you to run the following commands:

  • rsform:backup-forms: use this command to create backups for your forms
  • rsform:export-csv: use this command to export submissions from a specified form in CSV format
  • rsform:purge-submissions: use this command to delete submissions older than the configured number of days
 

The System - RSForm!Pro CLI plugin is installed by default with the component package. You will find it under System > Plugins area. Note that this is by default disabled and you will need to Enable it.

Works only on Joomla! 4 environments!

 

How to use the RSForm!Pro CLI commands

Below you will find out how to configure these CLI Commands for RSForm!Pro as well as some practical examples for each command.

 

Form Backups CLI command

Type the following to list available options for the forms backup command:

 

php joomla.php help rsform:backup-forms

 

Available options

  • -p, --path=PATH: you can set the path where the backup file will be stored. The default folder is the CLI folder ("your_website\cli").
  • -s, --submissions=SUBMISSIONS: this flag indicates if submissions should be included. 0 - do not include, 1 - include. By default, submissions are included.
  • -f, --form[=FORM]: select the form IDs you wish to generate a backup file, leave blank for all forms. (multiple values are allowed)
 

Form Backups CLI command examples:

  • The following command will create a backup of all your forms and submissions:

    • php joomla.php rsform:backup-forms

  • To store forms without submissions, use the following command:

    • php joomla.php rsform:backup-forms --submissions=0

  • To include specific forms, use the --form parameter to pass the specific Form ID:

    • php joomla.php rsform:backup-forms --form=1 --form=5 --form=23

  • To include specific forms and save them in a custom path, use the --form and -path parameter to pass the specific Form ID in a desired location (note that this must be added within the CLI folder):

    • php joomla.php rsform:backup-forms --form=1 --path=your_folder_name_here
 

CSV submissions export CLI command

Type the following to list available options for the CSV submissions export command:

 

php joomla.php help rsform:export-csv

 

Available options

  • -p, --path=PATH: you can set the path where the CSV file should be stored. The default path is to the CLI folder ("your_website\cli").
  • --filename=FILENAME: The CSV Export filename. Defaults to 'Default Export Filename': "export-{formId}-{domain}-{date}"
  • --headers=HEADERS: Flag indicating if headers should be included. 0 - do not include, 1 - include. By default, headers are included.
  • -d, --delimiter=DELIMITER: select the Delimiter for the CSV columns. By default, this is set to ","
  • -e, --enclosure=ENCLOSURE: select the Enclosure for the CSV columns. By default, this is set to "\""
  • -f, --form[=FORM]: the Form ID from which you want to export submissions. Note that this is required.
 

CSV Export submissions CLI command examples:

  • To export submissions from form ID #1, pass the --form=1 parameter:

    • php joomla.php rsform:export-csv --form=1

  • To exclude headers, pass --headers=0 (these are included by default):

    • php joomla.php rsform:export-csv --form=1 --headers=0

  • To specify a different path or filename:

    • php joomla.php rsform:export-csv --form=1 --path=/var/www --filename=my_export

  • To change the delimiter (by default a comma) and enclosure (by default a quote):

    • php joomla.php rsform:export-csv --form=1 --delimiter=; --enclosure=
 

Deleting Old submissions CLI command

Type the following command to delete all submissions that are older than the number of days specified in each form (under Form Properties > Form Info > 'Delete Submissions Older Than (Days)' option:

 

php joomla.php rsform:purge-submissions

 
 

 

Was this article helpful?

Yes No
Sorry about that