![]() |
Bearsampp 2025.8.29
|
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 | 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 240 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 368 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(), 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 351 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 106 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, and exec().
Referenced by getProcessUsingPort().
|
static |
Gets the operating system information.
Definition at line 294 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 138 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 78 of file class.batch.php.
References $port, $result, Util\endWith(), exec(), findExeByPid(), and Util\startWith().
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 446 of file class.batch.php.
References $bearsamppCore, Util\formatWindowsPath(), and Util\random().
Referenced by exec().
|
static |
Initializes MySQL using a specified path.
string | $path | The path to the MySQL initialization script. |
Definition at line 171 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 225 of file class.batch.php.
References exec(), and Util\logWarning().
Referenced by BinPostgresql\initData().
|
static |
Installs the PostgreSQL service.
Definition at line 185 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 160 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 254 of file class.batch.php.
References exec(), Util\formatWindowsPath(), and writeLog().
Referenced by Module\createSymlink().
|
static |
Restarts the application.
Definition at line 128 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 325 of file class.batch.php.
References exec().
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 313 of file class.batch.php.
References exec().
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 337 of file class.batch.php.
References exec().
Referenced by installPostgresqlService().
|
static |
Uninstalls the PostgreSQL service.
Definition at line 210 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(), and removeSymlink().
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.