Bearsampp 2025.8.29
Loading...
Searching...
No Matches
Symlinks Class Reference

Public Member Functions

 __construct ($root)

Static Public Member Functions

static deleteCurrentSymlinks ()

Data Fields

const APACHE_SYMLINK = 'apache'
const BRUNO_SYMLINK = 'bruno'
const COMPOSER_SYMLINK = 'composer'
const CONSOLEZ_SYMLINK = 'consolez'
const GHOSTSCRIPT_SYMLINK = 'ghostscript'
const GIT_SYMLINK = 'git'
const MAILPIT_SYMLINK = 'mailpit'
const MARIADB_SYMLINK = 'mariadb'
const MEMCACHED_SYMLINK = 'memcached'
const MYSQL_SYMLINK = 'mysql'
const NGROK_SYMLINK = 'ngrok'
const NODEJS_SYMLINK = 'nodejs'
const PERL_SYMLINK = 'perl'
const PHP_SYMLINK = 'php'
const PHPMYADMIN_SYMLINK = 'phpmyadmin'
const PHPPGADMIN_SYMLINK = 'phppgadmin'
const POSTGRESQL_SYMLINK = 'postgresql'
const PYTHON_SYMLINK = 'python'
const RUBY_SYMLINK = 'ruby'
const XLIGHT_SYMLINK = 'xlight'

Private Attributes

 $root

Detailed Description

Manages the creation and deletion of symbolic links for various components within the Bearsampp environment.

Definition at line 14 of file class.symlinks.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $root)

Constructs a Symlinks object and initializes paths to current directories.

Parameters
Root$rootThe root object associated with the Bearsampp environment.

Definition at line 47 of file class.symlinks.php.

48 {
49 $this->root = $root;
50 $this->initializePaths();
51 }

References $root.

Member Function Documentation

◆ deleteCurrentSymlinks()

deleteCurrentSymlinks ( )
static

Deletes all symbolic links listed in the arrayOfCurrents. Logs each operation's success or failure.

This method iterates over a predefined list of symbolic link paths and attempts to delete each one. If a symbolic link does not exist, an error is logged. If the deletion is successful, a debug message is logged.

@global Root $bearsamppRoot The root object providing access to system paths. @global Core $bearsamppCore The core object providing core functionalities.

Definition at line 63 of file class.symlinks.php.

64 {
66
67 // Check to see if purging is necessary
68 $appsPath = $bearsamppRoot->getAppsPath();
69 $binPath = $bearsamppRoot->getBinPath();
70 $toolsPath = $bearsamppRoot->getToolsPath();
71
72 $array = [
73 self::PHPMYADMIN_SYMLINK => $appsPath . '/phpmyadmin/current',
74 self::PHPPGADMIN_SYMLINK => $appsPath . '/phppgadmin/current',
75 self::APACHE_SYMLINK => $binPath . '/apache/current',
76 self::MARIADB_SYMLINK => $binPath . '/mariadb/current',
77 self::MEMCACHED_SYMLINK => $binPath . '/memcached/current',
78 self::MYSQL_SYMLINK => $binPath . '/mysql/current',
79 self::NODEJS_SYMLINK => $binPath . '/nodejs/current',
80 self::PHP_SYMLINK => $binPath . '/php/current',
81 self::POSTGRESQL_SYMLINK => $binPath . '/postgresql/current',
82 self::COMPOSER_SYMLINK => $toolsPath . '/composer/current',
83 self::CONSOLEZ_SYMLINK => $toolsPath . '/consolez/current',
84 self::GHOSTSCRIPT_SYMLINK => $toolsPath . '/ghostscript/current',
85 self::GIT_SYMLINK => $toolsPath . '/git/current',
86 self::NGROK_SYMLINK => $toolsPath . '/ngrok/current',
87 self::PERL_SYMLINK => $toolsPath . '/perl/current',
88 self::PYTHON_SYMLINK => $toolsPath . '/python/current',
89 self::RUBY_SYMLINK => $toolsPath . '/ruby/current',
90 self::XLIGHT_SYMLINK => $binPath . '/xlight/current',
91 self::MAILPIT_SYMLINK => $binPath . '/mailpit/current',
92 self::BRUNO_SYMLINK => $toolsPath . '/bruno/current'
93 ];
94
95 // Fix for PHP 8.2: Add null checks before accessing array elements
96 if (!is_array($array) || empty($array)) {
97 Util::logError('Current symlinks array is not initialized or empty.');
98 return;
99 }
100
101 // Purge "current" symlinks
102 foreach ($array as $name => $path) {
103 // Skip if path is null
104 if (empty($path)) {
105 continue;
106 }
107
108 if (!file_exists($path)) {
109 // Skip if the symlink doesn't exist - no need to log an error
110 continue;
111 }
112
113 // Simple approach: use rmdir for directories and unlink for files
114 if (is_dir($path)) {
115 if (@rmdir($path)) {
116 Util::logDebug('Deleted directory symlink: ' . $path);
117 }
118 } else {
119 if (@unlink($path)) {
120 Util::logDebug('Deleted file symlink: ' . $path);
121 }
122 }
123 }
124 }
global $bearsamppRoot
global $bearsamppCore
static logError($data, $file=null)
static logDebug($data, $file=null)

References $bearsamppCore, $bearsamppRoot, Util\logDebug(), and Util\logError().

Referenced by ActionQuit\processWindow().

Field Documentation

◆ $root

$root
private

Definition at line 40 of file class.symlinks.php.

Referenced by __construct().

◆ APACHE_SYMLINK

const APACHE_SYMLINK = 'apache'

Definition at line 18 of file class.symlinks.php.

◆ BRUNO_SYMLINK

const BRUNO_SYMLINK = 'bruno'

Definition at line 35 of file class.symlinks.php.

◆ COMPOSER_SYMLINK

const COMPOSER_SYMLINK = 'composer'

Definition at line 25 of file class.symlinks.php.

◆ CONSOLEZ_SYMLINK

const CONSOLEZ_SYMLINK = 'consolez'

Definition at line 26 of file class.symlinks.php.

◆ GHOSTSCRIPT_SYMLINK

const GHOSTSCRIPT_SYMLINK = 'ghostscript'

Definition at line 27 of file class.symlinks.php.

◆ GIT_SYMLINK

const GIT_SYMLINK = 'git'

Definition at line 28 of file class.symlinks.php.

◆ MAILPIT_SYMLINK

const MAILPIT_SYMLINK = 'mailpit'

Definition at line 34 of file class.symlinks.php.

◆ MARIADB_SYMLINK

const MARIADB_SYMLINK = 'mariadb'

Definition at line 19 of file class.symlinks.php.

◆ MEMCACHED_SYMLINK

const MEMCACHED_SYMLINK = 'memcached'

Definition at line 20 of file class.symlinks.php.

◆ MYSQL_SYMLINK

const MYSQL_SYMLINK = 'mysql'

Definition at line 21 of file class.symlinks.php.

◆ NGROK_SYMLINK

const NGROK_SYMLINK = 'ngrok'

Definition at line 29 of file class.symlinks.php.

◆ NODEJS_SYMLINK

const NODEJS_SYMLINK = 'nodejs'

Definition at line 22 of file class.symlinks.php.

◆ PERL_SYMLINK

const PERL_SYMLINK = 'perl'

Definition at line 30 of file class.symlinks.php.

◆ PHP_SYMLINK

const PHP_SYMLINK = 'php'

Definition at line 23 of file class.symlinks.php.

◆ PHPMYADMIN_SYMLINK

const PHPMYADMIN_SYMLINK = 'phpmyadmin'

Definition at line 16 of file class.symlinks.php.

◆ PHPPGADMIN_SYMLINK

const PHPPGADMIN_SYMLINK = 'phppgadmin'

Definition at line 17 of file class.symlinks.php.

◆ POSTGRESQL_SYMLINK

const POSTGRESQL_SYMLINK = 'postgresql'

Definition at line 24 of file class.symlinks.php.

◆ PYTHON_SYMLINK

const PYTHON_SYMLINK = 'python'

Definition at line 31 of file class.symlinks.php.

◆ RUBY_SYMLINK

const RUBY_SYMLINK = 'ruby'

Definition at line 32 of file class.symlinks.php.

◆ XLIGHT_SYMLINK

const XLIGHT_SYMLINK = 'xlight'

Definition at line 33 of file class.symlinks.php.


The documentation for this class was generated from the following file: