Greg's blog

Registering classes

In PHPDevShell classes can be registered into the framework, either manually (in a config file) or from the database (usually by a plugin installation).

A registered class can be instanciated with the built-in factory, allowing some nice features:
- auto instanciation
- singleton
- auto dependency injection
- class aliasing (i.e. class override)

Class aliasing means that you can provide a class which will be used instead of another class and still be a daughter of of this class ; for example let's say I want to override the default login mecanism:

Access to multiple database

I've been recently asked how you can connect to a database server different than the "master", that is the server where the PHPDS installation resides.

Actually it's very easy as long as the server is Mysql:

class test_connector extends PHPDS_legacyConnector
 protected function applyConfig($db_config = '')
  $this->dbHost = "localhost";
  $this->dbName = "test";
  $this->dbUsername = "username";
  $this->dbPassword = "userpassword";

class test_query extends PHPDS_query

 protected $connector = "test_connector";

New documentation page: ldap

I've just added a new page in the documentation: LDAP (a.k.a Active Directory). More to come...

Fields and accessors

Starting with 3.0.5, PHPDS_dependant offers a little new trick: read-only fields.

The problem is, when in a class you have a field which should be readable but not writable, you are often lead to make it protected and write an accessor. The resulting code is, well, not really smart:

class service extends PHPDS_dependant
	protected $quality = 'great';

	public function quality()
		return $this->quality;

From now on, just add the field, it will be read-only by default.


Plugin layout (and security)

Over the years the folder of each plugin has receive more and more structured stuffs. It's becoming quite cluttered and I feel it need some cleanup. Here is my proposition on a structure we could use:

Usage Note
...config/ holds the plugin.config.xml file, used by the Plugin Admin, and host-related config files.


(this will be part of the documentation, one day, but currently it's a work in progress so the APIs are not stable)

PHPDevShell provides a simple forms module. That means it helps you create simple forms easily. That also means if you need complex forms, you probably need more than this plugin.

There are two goals aimed with this plugins:
- it should be possible to create forms in basic html (for non-php fluent designers)
- it should provide data checking, specified only once (for both JS dynamic check and PHP post check)

PHPDevShell © 2010 - All rights reserved.