Using Zend Components not too complicated after all.

I have installed the ZendFramework Library to a central location and added it to the php include path.

The code below then worked very quickly and easily so I am now prepared to go further with this experiment.I found the answer here thanks to BrianM

By using a centrally loaded library and sharing it rather than installing to each vhost directory I don’t need to worry about either disk usage or dependencies. The Zend autoloader takes full care of the dependency issue as well.

Here is my test code which worked out of the box for once.

[sourcecode language=”php”]
error_reporting(E_ALL ^ E_NOTICE);

require_once ‘Zend/Loader/Autoloader.php’;
// instantiate the loader
$loader = Zend_Loader_Autoloader::getInstance();

// optional argument if you want the auto-loader to load ALL namespaces

$validator = new Zend_Validate_EmailAddress();
$email = "bad-test@invalid.u";
if ($validator->isValid($email)) {
echo "email address appears valid";
// email appears to be valid

} else {

// email is invalid; print the reasons

foreach ($validator->getMessages() as $messageId => $message) {

echo "<pre>Validation failure ‘$messageId’: $message\n";

echo "</pre>";


Be the first to comment

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.