![]() |
Bearsampp 2026.9.23
|
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 277 of file class.batch.php.
References $bearsamppCore, exec(), Path\formatWindowsPath(), and Path\getLnExe().
Referenced by Symlinks\createModuleSymlink().
|
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 453 of file class.batch.php.
References $bearsamppConfig, $result, UtilString\endWith(), getTmpFile(), and writeLog().
Referenced by OpenSsl\createCrt(), createSymlink(), OpenSsl\ensureRootCaExists(), Nssm\exec(), execStandalone(), findExeByPid(), BinApache\getCmdLineOutput(), BinMariadb\getCmdLineOutput(), BinMysql\getCmdLineOutput(), BinPostgresql\getCmdLineOutput(), getOsInfo(), getPearVersion(), getProcessUsingPort(), BinMariadb\initData(), initializeMariadb(), initializeMysql(), initializePostgresql(), installPostgresqlService(), OpenSsl\makeRootCa(), 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 435 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 125 of file class.batch.php.
References $bearsamppCore, $bearsamppRoot, execStandalone(), Path\getExeFilePath(), Path\getPhpExe(), Log\info(), Core\isRoot_FILE, Win32Ps\killBins(), 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 60 of file class.batch.php.
References $result, exec(), UtilInput\sanitizePID(), and writeLog().
Referenced by getProcessUsingPort().
|
static |
Gets the operating system information.
Definition at line 336 of file class.batch.php.
References $result, exec(), and UtilString\startWith().
Referenced by ActionStartup\sysInfos().
|
static |
Gets the version of PEAR installed.
Definition at line 157 of file class.batch.php.
References $bearsamppBins, $result, exec(), and UtilString\startWith().
Referenced by BinPhp\getPearVersion().
|
static |
Gets the process using a specific port.
| int | $port | The port number to check. |
Definition at line 88 of file class.batch.php.
References $port, $result, UtilString\endWith(), exec(), findExeByPid(), UtilInput\sanitizePort(), UtilString\startWith(), and writeLog().
Referenced by ServiceHelper\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 554 of file class.batch.php.
References $bearsamppCore, Path\formatWindowsPath(), Path\getTmpPath(), and UtilString\random().
Referenced by exec().
|
static |
Initializes MariaDB using a specified path.
| string | $path | The path to the MariaDB initialization script. |
Definition at line 261 of file class.batch.php.
References exec(), and Log\warning().
Referenced by BinMariadb\initData().
|
static |
Initializes MySQL using a specified path.
| string | $path | The path to the MySQL initialization script. |
Definition at line 190 of file class.batch.php.
References exec(), and Log\warning().
Referenced by BinMysql\initData().
|
static |
Initializes PostgreSQL using a specified path.
| string | $path | The path to the PostgreSQL initialization script. |
Definition at line 246 of file class.batch.php.
References exec(), and Log\warning().
Referenced by BinPostgresql\initData().
|
static |
Installs the PostgreSQL service.
Definition at line 205 of file class.batch.php.
References $bearsamppBins, exec(), Path\formatWindowsPath(), Path\getModuleSymlinkPath(), BinPostgresql\SERVICE_NAME, setServiceDescription(), setServiceDisplayName(), and setServiceStartType().
Referenced by Win32Service\create().
|
static |
Refreshes the environment variables.
Definition at line 179 of file class.batch.php.
References $bearsamppCore, $bearsamppRoot, Registry\APP_PATH_REG_ENTRY, execStandalone(), Path\formatWindowsPath(), Path\getRootPath(), and Path\getSetEnvExe().
Referenced by Registry\setValue().
|
static |
Removes a symbolic link.
| string | $link | The path to the symbolic link. |
Definition at line 292 of file class.batch.php.
References exec(), Path\formatWindowsPath(), and writeLog().
Referenced by Symlinks\createModuleSymlink().
|
static |
Restarts the application.
Definition at line 147 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 380 of file class.batch.php.
References exec(), UtilInput\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 356 of file class.batch.php.
References exec(), UtilInput\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 404 of file class.batch.php.
References exec(), UtilInput\sanitizeServiceName(), and writeLog().
Referenced by installPostgresqlService().
|
static |
Uninstalls the PostgreSQL service.
Definition at line 230 of file class.batch.php.
References $bearsamppBins, exec(), Path\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, Log\debug(), and Path\getBatchLogFilePath().
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.