 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
PHPMaster.com: Access the Windows Registry from PHP
by Chris Cornutt September 10, 2012 @ 15:27:26
New on PHPMaster.com today there's a tutorial showing you how to access the Windows registry with PHP with the help of the win32std extension.
The Windows Registry is simply a hierarchically structured database in which the Windows operating system and other applications store important configuration information. All sorts of data is stored in the registry: user profiles, file-type associations, hardware information, serial numbers, and more. With functions available from the win32std extension, your Windows-based PHP applications can access the registry too. The win32std extension can be downloaded as a pre-compiled library from downloads.php.net/pierre/. Simply drop it into your PHP's ext folder, update your php.ini file, and restart Apache if necessary.
The article talks a bit about the general layout of the registry, the main five keys and the encouragement of making a sandbox registry to perform your operations on rather than taking a chance. He shows how to use the extension's functions to read from the registry and write back out to a certain key. Their example application performs a check on the registry to see if a USB dongle is attached to the system based on a key being set and the device ID.
voice your opinion now!
windows registry extension win32std tutorial
Stuart Herbert's Blog: Getting PEAR Working On Windows 7
by Chris Cornutt May 10, 2012 @ 10:43:49
Stuart Herbert has a new post today showing how to get the well-established PEAR package management system working on Windows 7 so you can easily call "pear install" on whatever your needs might be.
So that I don't forget how to do this next time around. Worked for me, your mileage may vary. First step is to get a working install of PHP. [...] At this point, you should be able to open up a Command Prompt, and type 'php -v', and see the response 'PHP v5.4.latest …' appear as expected. Now for PEAR itself.
He gives step-by-step instructions on how to get PEAR up and running - downloading and configuring it with the correct Windows-based paths and using the PEAR_ENV.reg file to update your registry.
voice your opinion now!
pear windows7 install tutorial registry
Court Ewing's Blog: A Simple Alternative to Global Registry Dependency
by Chris Cornutt December 09, 2010 @ 15:19:22
Court Ewing has written up a post looking at an alternative to a commonly used bad design pattern - the global registry dependency - a method that uses a singleton to control access to a class-wide instance of an object.
This gives you flexibility when configuring and setting your adapter, and it allows you to instantiate a new service without having to explicitly set commonly used dependencies, but you are ultimately just replacing one hardcoded object call with another. This means you are still limited in your ability to unit test the class properly, and you will have a difficult time debugging if you ever need to find out exactly when and where your database adapter was configured.
In his simple solution uses static methods to assign the database adapter when the bootstrap process is started instead of when the object is created. This adapter is assigned to an abstract class, so it's created even outside the class instantiations. There's one caveat to doing things this way, though - depending on the needs, you might have to have more than one abstract class and things could get tricky.
voice your opinion now!
alternative global registry dependency example
Brandon Savage's Blog: The Registry Pattern Reexamined
by Chris Cornutt March 26, 2010 @ 12:57:04
Brandon Savage takes another look at a popular design pattern - the registry pattern - and how he's changed his thinking on its use a bit on how (or if) it should be used in your applications.
Last July, I wrote about the registry pattern and some of its advantages. These advantages include the ability to access objects across different areas of your application, and the storage of objects for later retrieval. [...] For me, over the last few months, I've discovered two reasons why I advise against the Registry Pattern: first and foremost, it discourages unit testing, and secondly, it discourages good design.
He goes on to elaborate on why these to things could be so detrimental to your code including the problems it can cause in tests being a point of failure and that it can make you application sloppy by giving you an unpoliced "bucket" to drop things in without any context to where they fit in the site.
So what's his suggestion to replace this bit of functionality and make things both easy to test and simpler to keep structured? Dependency injection.
voice your opinion now!
registry pattern unittest structure
Developer.com: Build your own MVC Framework Making Headway
by Chris Cornutt August 31, 2009 @ 09:09:06
Continuing on from the first part of the series, Marc Plotz forges ahead in his development of a PHP MVC (Model/View/Controller) framework. This new article gives a more complete overview of how the entire framework is structured.
Unlike the previous part, I am not simply giving you the part of the framework that we discuss, but a much more complete version. You will need a MySQL database to run it on, and you will have to setup the connection in application/db.ini.php. My example should guide you. You should not have to do much else than create the database and connect to it.
You can grab the source here and follow along with the tutorial as it steps through bootstrapping and a registry that replaces a "super global" handling method that could cause trouble.
voice your opinion now!
mvc framework tutorial bootstrap registry
Brandon Savage's Blog: Use Registry To Remember Objects (So You Don't Have To)
by Chris Cornutt July 22, 2009 @ 07:52:35
Brandon Savage has posted a quick look at using one of the more popular design patterns - Registry - to handle object storage and retrieval.
One of the biggest challenges in OOP programming with PHP is the ability to pass around objects and let other objects use them. This challenge can be solved with careful design, however. Here we will discuss the registry pattern, not a member of the GoF's original patterns but still an important pattern nonetheless.
He looks at a few different ways to solve a few different problems - first, sharing a database resource between multiple objects, then making sure that you have a connection no matter where its called from and finally - what the registry is used for - sharing multiple database connections between multiple objects. He uses static methods in an abstract class to handle the set/get of the correct object.
There's also a bit of discussion about the registry pattern versus dependency injection and which is better for most instances.
voice your opinion now!
dependencyinjection registry designpattern
PHPFreaks.com: Design Patterns - Strategy/Bridge, Value Object, Singleton (Registry)
by Chris Cornutt October 10, 2008 @ 09:33:10
Following up on their introduction to design patterns, the PHP Freaks have posted tutorials covering three of the more popular patterns - strategy/bridge, value object and singleton.
- Strategy and Bridge - The Strategy and Bridge patterns provide solutions to apply polymorphism in more flexible way than you can accomplish with only inheritance.
- Value Object - The Value Object pattern has, just like the Singleton, to do with referencing and instances. In a way, the Value Object is the opposite of the Singleton: it's goal is to ensure NOT to use the same instance, under certain conditions.
- Singleton and Singleton Registry - The Singleton pattern ensures that you are always dealing with the same, single instance, wherever in your application. The Registry pattern usually utilizes the Singleton pattern (hence "Singleton Registry") to make the same 'globalness' apply to objects who's classes weren't necessarily designed to
Keep checking back to their tutorials section for more design pattern tutorials.
voice your opinion now!
design pattern singleton registry valueobject strategy bridge
Debuggable Blog: Testing Models in CakePHP - Now let's get rid of the unnecessary ModelTest classes!
by Chris Cornutt July 31, 2008 @ 07:51:38
On the Debuggable blog today Tim Koschutzki looks at another testing topics for the CakePHP framework - a cleaner way for testing models.
Up until now there was always a need to create a so-called test model that extends your model-under-test in order to overwrite its $useDbConfig setting to be 'test_suite'. By that you ensured that your models run with the test_suite datasource when the tests are run. [...] Nate proposed ClassRegistry::config(), which allows you to tell the ClassRegistry class which datasource it shall use when
ClassRegistry::init() is used the next time (and thereby a model is instantiated).
He includes an example of the new functionality - a test case ensuring that three articles are there and are marked as published. The registry makes it easier to automatically create the ArticleTest instance inside the test case rather than having to manually declare and define it.
voice your opinion now!
test case cakephp framework registry modeltest class
|
Community Events
Don't see your event here? Let us know!
|