PHP Classes

PHP Access Windows Registry Access: Access and manipulate the Windows registry values

Recommend this page to a friend!
  Info   View files Documentation   View files View files (21)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2022-03-07 (9 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 73 All time: 10,012 This week: 138Up
Version License PHP version Categories
digilive-windows-reg 1.0Custom (specified...7.2Windows, Configuration, PHP 7
Description Author

This package can access and manipulate the Windows registry values.

It can perform several Windows registry configuration values like creating new keys, changing fundamental values, or deleting existing keys.

It can also convert the values between the Windows registry and PHP types.

The package also provides iterators to traverse the keys' values with sub-keys.

Innovation Award
PHP Programming Innovation award nominee
March 2022
Number 2


Prize: SourceGuarding PHP encoder tool
Windows Registry is a central place in installing a Windows operating system that contains the configuration of system values.

In some cases, the Windows Registry configuration values have complex keys and sub-keys.

This package makes it easy to access those complex values by providing an iterator that can access each sub-key one at a time.

Manuel Lemos
Picture of DigiLive
  Performance   Level  
Name: DigiLive <contact>
Classes: 2 packages by
Country: The Netherlands The Netherlands
Age: 44
All time rank: 4387103 in The Netherlands The Netherlands
Week rank: 587 Up17 in The Netherlands The Netherlands Up
Innovation award
Innovation award
Nominee: 1x

Details

Windows Registry Wrapper

GitHub release (latest by date including pre-releases) Codacy Badge GitHub license

A small library for accessing and manipulating the Registry on Microsoft Windows systems. For that one time you need to access the Windows Registry in a PHP application.

This library can be (and has been) used in production code, but please consider reading the disclaimer below before using.

Features

  • Read and write access to any hive, key, or value in the registry (that you have permissions to)
  • Automatic conversion between all registry value data types to PHP scalar types
  • Lazy-loaded iterators over lists of values and recursive iterators over keys and subKeys
  • Ability to connect to registries on remote computers using a remote WMI (Windows Management Instrumentation) connection (see Microsoft's docs on how to connect to WMI remotely for details)

Requirements

  • Microsoft Windows (Vista or newer) or Windows Server (Windows Server 2003 or newer)
  • PHP com_dotnet extension

Installation

Use Composer:

> composer require digilive/windows-registry:~0.10

Note: This package replaces package coderstephen/windows-registry v0.9.1 which has been abandoned.

Documentation

Full API documentation is available online here.

Examples

Below is an example of creating a new registry key with some values and then deleting them.

use Windows\Registry;

$hklm = Registry\Registry::connect()->getLocalMachine();
$keyPath = 'Software\\MyKey\\MySubKey';

// create a new key
try
{
    $mySubKey = $hklm->createSubKey($keyPath);
}
catch (Registry\Exception $e)
{
    print "Key '{$keyPath}' not created" . PHP_EOL;
}

// create a new value
$mySubKey->setValue('Example DWORD Value', 250, Registry\RegistryKey::TYPE_DWORD);

// delete the new value
$mySubKey->deleteValue('Example DWORD Value');

// delete the new key
try
{
    $hklm->deleteSubKey($keyPath);
}
catch (Registry\Exception $e)
{
    print "Key '{$keyPath}' not deleted" . PHP_EOL;
}

You can also iterate over subKeys and values using built-in iterators:

foreach ($key->getSubKeyIterator() as $name => $subKey)
{
    print $subKey->getQualifiedName() . PHP_EOL;
}

foreach ($key->getValueIterator() as $name => $value)
{
    printf("%s: %s\r\n", $name, $value);
}

Disclaimer

Messing with the Windows Registry can be dangerous; Microsoft has plenty of warnings about how it can destroy your installation. Not only should you be careful when accessing the Registry, this library is not guaranteed to be 100% safe to use and free of bugs. Use discretion, and test your code in a virtual machine if possible. We are not liable for any damages caused by this library. See the license for details.

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (10 files)
Files folder imagetests (5 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageISSUE_TEMPLATE (2 files)

  Files folder image Files  /  .github  /  ISSUE_TEMPLATE  
File Role Description
  Accessible without login Plain text file bug_report.md Data Auxiliary data
  Accessible without login Plain text file feature_request.md Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file Exception.php Class Class source
  Plain text file InvalidTypeException.php Class Class source
  Plain text file KeyNotFoundException.php Class Class source
  Plain text file OperationFailedException.php Class Class source
  Plain text file Registry.php Class Class source
  Plain text file RegistryHandle.php Class Class source
  Plain text file RegistryKey.php Class Class source
  Plain text file RegistryKeyIterator.php Class Class source
  Plain text file RegistryValueIterator.php Class Class source
  Plain text file ValueNotFoundException.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file RegistryHandleTest.php Class Class source
  Plain text file RegistryKeyIteratorTest.php Class Class source
  Plain text file RegistryKeyTest.php Class Class source
  Plain text file RegistryTest.php Class Class source
  Plain text file RegistryValueIteratorTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:73
This week:0
All time:10,012
This week:138Up