Re: validation extension

From: Date: Sat, 14 Aug 2004 10:15:51 +0000
Subject: Re: validation extension
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-1154@lists.php.net to get a copy of this message
Thanks for the feedback, Yeah i looked at ext/pcre and i have not had heaps of experience with C and found it difficult to work out what to do :(, so i just used call_user_function to get it working to begin with. I'll have a look at APC and see if i can work it out. This is mainly a tool to work out the PHP internals and get used to libxml2. I have a different approach in mind that may make it easier to do some of the things you are talking about. (i think anyway). Rasmus Lerdorf wrote:
Seems like an interesting approach. Have you done any performance testing on this to see exactly what sort of performance impact it has compared to no validation and compared to more traditional PHP-based validation. I see a couple of problems with the implementation. First, using call_user_function to preg_match() to apply a regex is non-optimal. We have a PHPAPI function exposed by ext/pcre called pcre_get_compiled_regex() and then you can just call pcre_exec() directly. Second, this would make sense to implement as a PHP5 input filter. Have a look at README.input_filter in the php5 tree and specifically the example implementation there. And getting back to the performance worry. These XML files should be relatively simple and generating the DOM tree for them on every request seems like a waste of cycles. The SAX interface in libxml2 is faster than the DOM interface you are using and would be preferred if it needs to be done on every request. But perhaps a more creative solution exists for that? What about a DOM tree cache? This might be something beyond just this extension though. It might make sense to have a generic shared memory DOM tree cache of some sort, or perhaps even piggyback it on top of APC. APC already has all the mechanisms in place for handling shared memory cacheing of stuff. -Rasmus On Sat, 14 Aug 2004, nick loeve wrote:
Hi, I have the start of an extension for validation based on rules defined as xml. Each rule can currently validate GET and POST variables: - validating their existence - validating regular expressions - integer ranges. The extension defines a single function for the moment, and this function enforces a rule in a certain file. The functionality is limited and the design not the greatest, but i have some different things i would like to be able to define in regards to automated validation from XML. If someone gets a chance could have a look at the code and see what may be required in order for this extension to be granted a listing at pecl. Thanks Nick -- PECL development discussion Mailing List (http://pecl.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.pecl.dev (#1154) next »