Recommend this page to a friend! |
Classes of Christian Vigh | PHP Wamp Server Installation Manager | README.md | Download |
|
DownloadINTRODUCTIONWamp has a really fine user interface, but it's not always straightforward to understand how various Apache, MySql and PHP versions are or can be installed. The WampManager class allows you to drive Wamp from within a script ; it provides the following features :
Instantiating a WampManager object is fairly simple :
If the class finds a valid WAMP installation directoy on your system, it will return a valid instance ; otherwise, an exception will be thrown. You will have access to properties such as PhpPackages, MySqlPackages and ApachePackages which are array objects giving you access to the settings of each package. The Php, MySql and Apache properties will return you the currently active version of each product. You will also have access to the WAMP installation and logs directories through the InstallationDirectory and LogsDirectory properties. The WampExecutable property will give you the complete path of WAMPMANAGER.EXE. The WampManager::$WampManagerConfiguration static property wraps the contents of the WampManager.conf .INI file located at the root of the installation directory and allows you to retrieve or change settings. REFERENCEWampManager classThe WampManager class is the top-level class to access the inner settings of your WAMP configuration, start and stop services, etc. MethodsConstructor
Creates a WampManager class instance and reads all the settings defined in your current installation. Note that creating a WampManager instance does not mean launch WampManager. At this stage, only an object is created, and it does not affect your running instance of Wamp. The class searches the root of each of all your non-removable partitions to locate a directory that looks like "\Wamp\". Of course, if such a directory has been found, it effectively checks that it contains the traditional tree hierarchy of Wamp ; this means :
You can override this behavior by defining the WAMPDIR environment variable to point to your Wamp installation directory. ConfigurationChanged
Call this method whenever you have made any changes to the WampManager.conf file through the WampManager::$WampManagerConfiguration object. It will save any changes performed so far and restart Wamp. Restart
Restarts all the running services (Apache and MySql) along with Wamp itself. Debug messages will be displayed if the $verbose parameter is set to true. Note that PHP itself is not to be considered as a service : it is a DLL used by Apache. SaveConfiguration
Saves the currently loaded Wamp configuration. This method is a shortcut for :
Start
Starts all the Wamp services (Apache and MySql). Debug messages will be displayed if the $verbose parameter is set to true. Note that PHP itself is not to be considered as a service : it is a DLL used by Apache. Stop
Stops all the Wamp services (Apache and MySql). Debug messages will be displayed if the $verbose parameter is set to true. Note that PHP itself is not to be considered as a service : it is a DLL used by Apache.
PropertiesApacheReturns the currently active Apache version (of type ApachePackage). ApachePackagesAn array of type ApachePackages containing ApachePackage objects that give information about your currently installed Apache versions. InstallationDirectoryReturns the directory of your current Wamp installation. LogDirectoryReturns the logs directory of your current Wamp installation (normally, unless modified, this should be a directory named logs directly under the installation directory). MySqlReturns the currently active MySql version (of type MySqlPackage). MySqlPackagesAn array of type MySqlPackages containing MySqlPackage objects that give information about your currently installed MySql versions. PhpReturns the currently active PHP version (of type PhpPackage). PhpPackagesAn array of type PhpPackages containing PhpPackage objects that give information about your currently installed PHP versions. WampExecutableReturns the full path of WAMPMANAGER.EXE. WampManagerConfigurationThis static property gives you access to your current Wamp settings, through an object of type IniFile. You can retrieve them and modify them. You can find more information about the IniFile class here :
Packages collections (WampPackages classes)The WampManager package comes with 3 classes that represent a collection of installed Wamp packages :
Each collection inherits from the WampPackages file. They currently do not add any new behavior to their base class, but only have different constructor parameters. The ApachePackage and MySqlPackage classes inherit from the WampService class ; the PhpPackage class inherits from WampModule. Both WampService and WampModule classes inherit from WampPackage. The following sections describe the properties and methods of the WampPackages class, which apply to all of its derived classes. Since this class is mainly used internally, most of the properties and methods are given here for informational purposes only. Note that this class implements the ArrayAccess, Countable and Iterator interface, so that you can loop through a package list as if it were an array. MethodsConstructor
Creates a list of Packages whose configuration information is to be loaded. Since this is an abstract class, it is the responsibility of derived classes (PhpPackages, MySqlPackages and ApachePackages) to provide the required parameters appropriate to their function. The parameters are the following :
Note that the documentation about this constructor is for informational purposes only, since it is used internally by the WampManager class. GetActivePackage
Returns the object corresponding to the currently active version of the related product (PhpPackage for PHP, MySqlPackage for Mysql and ApachePackage for Apache. A typical usage could be :
which is also equivalent to :
GetActiveVersion
Returns the active version as a string for the related product. A typical usage could be :
GetVersions
Returns a list of versions for the related product ; the following example retrieves the currently installed PHP versions :
SetVersion
Sets the currently active version. If the $reload parameter is false, the change will be effective after restarting WAMP. VersionExists
Checks if the specified version exists. This is equivalent to :
PropertiesNameReturns the underlying name of the package collection : either "PHP", "MySql" or "Apache". Package classesPackage classes are objects contained in a package list ; they have the following hierarchy :
WampPackage is the abstract base class for all WAMP modules (Apache, MySql and Php). The WampModule class further defines the behavior of an installed module. Then comes a fork in the hierarchy :
The following sections describe the methods and properties exposed by each class. Package class : WampPackageThe WampPackage is the abstract base class for all WAMP modules. MethodsConstructor
Instantiates a WampPackage object ; the parameters are the following :
Note : this constructor is used internally. It is not meant to be called from within a script. GetConfigurationFiles
This abstract function is meant to return the paths of all the configuration files handled by the underlying package. GetLogFiles
This abstract function is meant to return the paths of all the log files handled by the underlying package. PropertiesConfigurationDirectoryReturns the path of the configuration directory for the underlying package. ConfigurationFileReturns the path of the main configuration file for the underlying package. ExecutableFileReturns the path of the executable file for the underlying package. NameReturns the name of the underlying package (PHP, MySql or Apache). PathReturns the installation path of the underlying package. VersionReturns the package version string. Package class : WampModuleThis class extends the WampPackage class by adding the following methods : IsRunning
Checks if the specified module is currently running. Restart
Restarts the specified module or service. Start
Starts the specified module or service. Stop
Stops the specified module or service. Package class : WampServiceThis class extends the WampPackage class by adding the methods described below ; note that the Install/Uninstall methods are not yet implemented to create/remove new httpd services and will throw an exception. Install
Installs a new instance (Windows service) of the underlying package. Uninstall
Uninstalls a existing WAMP Windows service. Package class : ApachePackageThis class extends the WampService class by adding the following methods : GetModules
Returns the list of currenly declared Apache modules. Package class : MySqlPackageThis class can install additional Windows MySql services or remove them. Note that in the supplied configuration file, the main section name defining the host port, the database directory, etc. must match the service name you supply to the Install()* method. For example, WAMP 64-bits has a section named [wampmysqld64] in its my.ini file. If you want to install a service named "foobar", then the configuration file you specified will need to have a [foobar] section for defining MySql parameters. A gentle reminder :
Package class : PhpPackageThis class extends the WampService class by adding the following methods : GetModules
Returns the list of currenly declared PHP modules. |