2017 © Pedro Peláez
 

library windows-registry

A small library for accessing and manipulating the Windows registry

image

coderstephen/windows-registry

A small library for accessing and manipulating the Windows registry

  • Thursday, January 11, 2018
  • by sagebind
  • Repository
  • 1 Watchers
  • 7 Stars
  • 32 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

Windows Registry Wrapper

Build Version Code Quality License, (*1)

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

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

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:, (*4)

> composer require coderstephen/windows-registry:~0.9

Documentation

Full API documentation is available online here., (*5)

Examples

Below is an example of creating a new registry key with some values and then deleting them., (*6)

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:, (*7)

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. I am not liable for any damages caused by this library. See the license for details., (*8)

The Versions

11/01 2018

dev-master

9999999-dev

A small library for accessing and manipulating the Windows registry

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3
  • ext-com_dotnet *

 

The Development Requires

windows registry win32

16/05 2015

v0.9.1

0.9.1.0

A small library for accessing and manipulating the Windows registry

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3
  • ext-com_dotnet *

 

The Development Requires

windows registry win32

15/05 2015

v0.9

0.9.0.0

A small library for accessing and manipulating the Windows registry

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3
  • ext-com_dotnet *

 

The Development Requires

windows registry win32