Skip to content

functions_modules_cli

Daniel Spors edited this page Dec 19, 2023 · 3 revisions

Functions in file modules/cli.php

cli_init

Initializes the CLI module. This is a semi-automatic module that provides you with the ability to process application logik defined in Task subclasses from the commandline. You may even delay them to be processed in the background later.

// sample:	
php index.php clear-logs	

See Task, WdfTaskModel, ClearTask, DbTask

Definition: public function cli_init()

Returns: void

cli_run_script

Runs a PHP script with given arguments in CLI. Note that WDF generates a temporary php.ini file with the current loaded INI settings and uses it for the php commandline (php -c). The script will be run in background using nohup and stdout/stderr is redirected to current error_log. There will be some special arguments generated and passed to the script: -D<path_to_datafile> Path to a file containing the serialized $_SERVER vairable -C<path_to_configfile> Path to the currently loaded WDF config.php file -A<appname> The name of the current WDF application (see system_init).

Definition: public function cli_run_script($php_script_path, $args, $extended_data=false, $return_cmdline=false)

Returns: void|string

Parameters:

  • string $php_script_path The script path

  • array $args All arguments

  • array $extended_data Optional additional data to pass to the process

  • bool $return_cmdline If true will not execute, but just return the commandline

cli_list_processes

INTERNAL Lists all processes.

cli_running_as_sudo

INTERNAL Detects if script is running as root.

cli_run_taskprocessor

INTERNAL Runs a PHP process for background task processing

cli_get_processes

INTERNAL Used to check if processes are already active

cli_execute

INTERNAL Processes CLI arguments including doing work on detected Tasks

Clone this wiki locally