|
Bearsampp 2026.3.26
API documentation
|
Public Member Functions | |
| __construct () | |
Static Public Member Functions | |
| static | createSymlink ($src, $dest) |
| static | exec ($basename, $content, $timeout=true, $catchOutput=true, $standalone=false, $silent=true, $rebuild=true) |
| static | execStandalone ($basename, $content, $silent=true) |
| static | exitApp ($restart=false) |
| static | findExeByPid ($pid) |
| static | getOsInfo () |
| static | getPearVersion () |
| static | getProcessUsingPort ($port) |
| static | initializeMariadb ($path) |
| static | initializeMysql ($path) |
| static | initializePostgresql ($path) |
| static | installPostgresqlService () |
| static | refreshEnvVars () |
| static | removeSymlink ($link) |
| static | restartApp () |
| static | setServiceDescription ($serviceName, $desc) |
| static | setServiceDisplayName ($serviceName, $displayName) |
| static | setServiceStartType ($serviceName, $startType) |
| static | uninstallPostgresqlService () |
Data Fields | |
| const | CATCH_OUTPUT_FALSE = 'bearsamppCatchOutputFalse' |
| const | END_PROCESS_STR = 'FINISHED!' |
Static Private Member Functions | |
| static | getTmpFile ($ext, $customName=null) |
| static | writeLog ($log) |
Class Batch
This class provides various utility functions for managing processes, services, and environment variables within the Bearsampp application. It includes methods for finding executables by process ID, checking which process is using a specific port, exiting and restarting the application, managing services, and executing batch scripts.
Key functionalities include:
The class utilizes global variables to access application settings and paths, and logs operations for debugging purposes.
Definition at line 30 of file class.batch.php.
| __construct | ( | ) |
|
static |
Creates a symbolic link.
| string | $src | The source path. |
| string | $dest | The destination path. |
Definition at line 268 of file class.batch.php.
References $bearsamppCore, exec(), and Util\formatWindowsPath().
Referenced by Module\createSymlink().
|
static |
Executes a batch script.
| string | $basename | The base name for the script and result files. |
| string | $content | The content of the batch script. |
| int | bool | $timeout | The timeout for the script execution in seconds, or true for default timeout, or false for no timeout. |
| bool | $catchOutput | Whether to capture the output of the script. |
| bool | $standalone | Whether the script is standalone. |
| bool | $silent | Whether to execute the script silently. |
| bool | $rebuild | Whether to rebuild the result array. |
Definition at line 432 of file class.batch.php.
References $bearsamppConfig, $result, Util\endWith(), getTmpFile(), and writeLog().
Referenced by OpenSsl\createCrt(), createSymlink(), Nssm\exec(), execStandalone(), findExeByPid(), BinApache\getCmdLineOutput(), BinMariadb\getCmdLineOutput(), BinMysql\getCmdLineOutput(), BinPostgresql\getCmdLineOutput(), getOsInfo(), getPearVersion(), getProcessUsingPort(), BinMariadb\initData(), initializeMariadb(), initializeMysql(), initializePostgresql(), installPostgresqlService(), removeSymlink(), setServiceDescription(), setServiceDisplayName(), setServiceStartType(), and uninstallPostgresqlService().
|
static |
Executes a standalone batch script.
| string | $basename | The base name for the script and result files. |
| string | $content | The content of the batch script. |
| bool | $silent | Whether to execute the script silently. |
Definition at line 415 of file class.batch.php.
References exec().
Referenced by exitApp(), and refreshEnvVars().
|
static |
Exits the application, optionally restarting it.
| bool | $restart | Whether to restart the application after exiting. |
Definition at line 120 of file class.batch.php.
References $bearsamppCore, $bearsamppRoot, execStandalone(), Core\isRoot_FILE, Win32Ps\killBins(), Util\logInfo(), and Action\RESTART.
Referenced by ActionExec\__construct(), and restartApp().
|
static |
Finds the executable name by its process ID (PID).
| int | $pid | The process ID to search for. |
Definition at line 59 of file class.batch.php.
References $result, exec(), Util\sanitizePID(), and writeLog().
Referenced by getProcessUsingPort().
|
static |
Gets the operating system information.
Definition at line 322 of file class.batch.php.
References $result, exec(), and Util\startWith().
Referenced by ActionStartup\sysInfos().
|
static |
Gets the version of PEAR installed.
Definition at line 152 of file class.batch.php.
References $bearsamppBins, $result, exec(), and Util\startWith().
Referenced by BinPhp\getPearVersion().
|
static |
Gets the process using a specific port.
| int | $port | The port number to check. |
Definition at line 85 of file class.batch.php.
References $port, $result, Util\endWith(), exec(), findExeByPid(), Util\sanitizePort(), Util\startWith(), and writeLog().
Referenced by Util\isPortInUse().
|
staticprivate |
Gets a temporary file path with a specified extension and optional custom name.
| string | $ext | The file extension. |
| string | null | $customName | An optional custom name for the file. |
Definition at line 510 of file class.batch.php.
References $bearsamppCore, Util\formatWindowsPath(), and Util\random().
Referenced by exec().
|
static |
Initializes MariaDB using a specified path.
| string | $path | The path to the MariaDB initialization script. |
Definition at line 253 of file class.batch.php.
References exec(), and Util\logWarning().
Referenced by BinMariadb\initData().
|
static |
Initializes MySQL using a specified path.
| string | $path | The path to the MySQL initialization script. |
Definition at line 185 of file class.batch.php.
References exec(), and Util\logWarning().
Referenced by BinMysql\initData().
|
static |
Initializes PostgreSQL using a specified path.
| string | $path | The path to the PostgreSQL initialization script. |
Definition at line 239 of file class.batch.php.
References exec(), and Util\logWarning().
Referenced by BinPostgresql\initData().
|
static |
Installs the PostgreSQL service.
Definition at line 199 of file class.batch.php.
References $bearsamppBins, exec(), Util\formatWindowsPath(), BinPostgresql\SERVICE_NAME, setServiceDescription(), setServiceDisplayName(), and setServiceStartType().
Referenced by Win32Service\create().
|
static |
Refreshes the environment variables.
Definition at line 174 of file class.batch.php.
References $bearsamppCore, $bearsamppRoot, Registry\APP_PATH_REG_ENTRY, execStandalone(), and Util\formatWindowsPath().
Referenced by Registry\setValue().
|
static |
Removes a symbolic link.
| string | $link | The path to the symbolic link. |
Definition at line 282 of file class.batch.php.
References exec(), Util\formatWindowsPath(), and writeLog().
Referenced by Module\createSymlink().
|
static |
Restarts the application.
Definition at line 142 of file class.batch.php.
References exitApp().
Referenced by ActionExec\__construct().
|
static |
Sets the description of a service.
| string | $serviceName | The name of the service. |
| string | $desc | The description to set. |
Definition at line 364 of file class.batch.php.
References exec(), Util\sanitizeServiceName(), and writeLog().
Referenced by installPostgresqlService().
|
static |
Sets the display name of a service.
| string | $serviceName | The name of the service. |
| string | $displayName | The display name to set. |
Definition at line 341 of file class.batch.php.
References exec(), Util\sanitizeServiceName(), and writeLog().
Referenced by installPostgresqlService().
|
static |
Sets the start type of a service.
| string | $serviceName | The name of the service. |
| string | $startType | The start type to set (e.g., "auto", "demand"). |
Definition at line 387 of file class.batch.php.
References exec(), Util\sanitizeServiceName(), and writeLog().
Referenced by installPostgresqlService().
|
static |
Uninstalls the PostgreSQL service.
Definition at line 224 of file class.batch.php.
References $bearsamppBins, exec(), Util\formatWindowsPath(), and BinPostgresql\SERVICE_NAME.
Referenced by Win32Service\delete().
|
staticprivate |
Writes a log entry to the batch log file.
| string | $log | The log message to write. |
Definition at line 47 of file class.batch.php.
References $bearsamppRoot, and Util\logDebug().
Referenced by exec(), findExeByPid(), getProcessUsingPort(), removeSymlink(), setServiceDescription(), setServiceDisplayName(), and setServiceStartType().
| const CATCH_OUTPUT_FALSE = 'bearsamppCatchOutputFalse' |
Definition at line 33 of file class.batch.php.
| const END_PROCESS_STR = 'FINISHED!' |
Definition at line 32 of file class.batch.php.