Recommend this page to a friend! |
Download |
Info | Example | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
52% | Total: 235 | All time: 8,097 This week: 455 |
Version | License | PHP version | Categories | |||
wampmanager 1.0 | BSD License | 5.6 | HTTP, PHP 5, Databases, Systems admin..., W... |
<?php
|
Wamp 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 :
include ( 'WampManager.phpclass' ) ;
$wamp = new WampManager ( ) ;
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.
The WampManager class is the top-level class to access the inner settings of your WAMP configuration, start and stop services, etc.
$wamp = new WampManager ( ) ;
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.
$wamp -> 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.
$wamp -> Restart ( $verbose = false ) ;
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.
$wamp -> SaveConfiguration ( ) ;
Saves the currently loaded Wamp configuration.
This method is a shortcut for :
WampManager::$WampManagerConfiguration -> Save ( ) ;
$wamp -> Start ( $verbose = false ) ;
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.
$wamp -> Stop ( $verbose = false ) ;
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.
Returns the currently active Apache version (of type ApachePackage).
An array of type ApachePackages containing ApachePackage objects that give information about your currently installed Apache versions.
Returns the directory of your current Wamp installation.
Returns the logs directory of your current Wamp installation (normally, unless modified, this should be a directory named logs directly under the installation directory).
Returns the currently active MySql version (of type MySqlPackage).
An array of type MySqlPackages containing MySqlPackage objects that give information about your currently installed MySql versions.
Returns the currently active PHP version (of type PhpPackage).
An array of type PhpPackages containing PhpPackage objects that give information about your currently installed PHP versions.
Returns the full path of WAMPMANAGER.EXE.
This 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 :
https://www.phpclasses.org/package/9413-PHP-Load-and-edit-configuration-INI-format-files.html
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.
$Packages = new WampPackages ( $name, $class, $parent, $rootdir, $prefix, $active_version ) ;
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.
$package = $packages -> 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 :
$package = $wamp -> MySqlPackages -> GetActivePackage ( ) ;
which is also equivalent to :
$package = $wamp -> MySql ;
$version = $packages -> GetActiveVersion ( ) ;
Returns the active version as a string for the related product. A typical usage could be :
$version = $wamp -> PhpPackages -> GetActiveVersion ( ) ;
$list = $packages -> GetVersions ( ) ;
Returns a list of versions for the related product ; the following example retrieves the currently installed PHP versions :
$versions = $wamp -> PhpPackages -> GetVersions ( ) ;
$status = $packages -> SetVersion ( $version, $reload = true ) ;
Sets the currently active version. If the $reload parameter is false, the change will be effective after restarting WAMP.
$status = $packages -> VersionExists ( $version ) ;
Checks if the specified version exists. This is equivalent to :
$status = isset ( $packages [ $version ] ) ;
Returns the underlying name of the package collection : either "PHP", "MySql" or "Apache".
Package classes are objects contained in a package list ; they have the following hierarchy :
WampPackage
|
WampModule
|
+---------------+--------------+
| |
WampService PhpPackage
|
+---------------+--------------+
| |
ApachePackage MySqlPackage
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.
The WampPackage is the abstract base class for all WAMP modules.
$package = new WampPackage ( $name, $parent, $path, $version, $exedir, $exefile, $confdir, $conffile ) ;
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.
$files = $package -> GetConfigurationFiles ( ) ;
This abstract function is meant to return the paths of all the configuration files handled by the underlying package.
$files = $package -> GetLogFiles ( ) ;
This abstract function is meant to return the paths of all the log files handled by the underlying package.
Returns the path of the configuration directory for the underlying package.
Returns the path of the main configuration file for the underlying package.
Returns the path of the executable file for the underlying package.
Returns the name of the underlying package (PHP, MySql or Apache).
Returns the installation path of the underlying package.
Returns the package version string.
This class extends the WampPackage class by adding the following methods :
$status = $package -> IsRunning ( ) ;
Checks if the specified module is currently running.
$package -> Restart ( ) ;
Restarts the specified module or service.
$package -> Start ( ) ;
Starts the specified module or service.
$package -> Stop ( ) ;
Stops the specified module or service.
This 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.
$package -> Install ( $service_name, $configuration_file ) ;
Installs a new instance (Windows service) of the underlying package.
$package -> Uninstall ( $service_name ) ;
Uninstalls a existing WAMP Windows service.
This class extends the WampService class by adding the following methods :
$list = $package -> GetModules ( ) ;
Returns the list of currenly declared Apache modules.
This 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 :
This class extends the WampService class by adding the following methods :
$list = $package -> GetModules ( ) ;
Returns the list of currenly declared PHP modules.
Files (21) |
File | Role | Description | ||
---|---|---|---|---|
Src (9 files, 1 directory) | ||||
example.php | Example | Example script | ||
LICENSE | Lic. | License text | ||
NOTICE | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (21) | / | Src |
File | Role | Description | ||
---|---|---|---|---|
Dependencies (8 files) | ||||
ApachePackage.phpclass | Class | Class source | ||
ApachePackages.phpclass | Class | Class source | ||
MySqlPackage.phpclass | Class | Class source | ||
MySqlPackages.phpclass | Class | Class source | ||
PhpPackage.phpclass | Class | Class source | ||
PhpPackages.phpclass | Class | Class source | ||
WampManager.phpclass | Class | Class source | ||
WampPackage.phpclass | Class | Class source | ||
WampPackages.phpclass | Class | Class source |
Files (21) | / | Src | / | Dependencies |
File | Role | Description |
---|---|---|
AssociativeArray.phpclass | Class | Class source |
IniFile.phpclass | Class | Class source |
LogicalDrives.phpclass | Class | Class source |
Path.phpclass | Class | Class source |
String.phpclass | Class | Class source |
Variables.phpclass | Class | Class source |
Wmi.phpclass | Class | Class source |
WShell.phpclass | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
wampmanager-2017-04-13.zip 106KB | |
wampmanager-2017-04-13.tar.gz | |
Install with Composer |
Needed packages | ||
Class | Download | Why it is needed | Dependency |
---|---|---|---|
Extended Ini File | .zip .tar.gz | dependency | Optional |
Windows PHP WMI Class | .zip .tar.gz | dependency | Optional |
PHP List Windows Drives | .zip .tar.gz | dependency | Optional |
PHP Path Windows and Linux Utilities | .zip .tar.gz | dependency | Optional |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Ratings | ||||||||||||||||||||||||||||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.