Friday
18
July
2008

Zend Framework 1.6 RC1

Hy fellows,

a new version of Zend Framework will be released on Monday 21.July.2008.
It\’s the release canidate for 1.6. Even if it\’s until now not finished for public release, a release canidate can contain minor problems, it contains some new components and, of course, a huge amount of bugfixes and improvements.

My additions to this release are:
Zend_Transfer_Adapter_Ini: A adapter for using ini files for translations
Zend_File_Transfer: A component which handles file uploads and downloads for multiple transfer protocols.

Of course also a number of bugs and other small improvments to existing I18N components have been integrated.

Zend_File_Transfer is far away from being finished. But the ZF-devteam has decided that it should be integrated with 1.6. Actually it will support only the HTTP POST protocol. But it’s easy to use and it comes also with some validators especially created for file validation. As this component is not completly ready for now, it will additionally get an Zend_Form_Element_File which consumes this component, the decission has been made to delay it’s integration until RC2.

Yes, this are the bad news… we will have a RC2 anyway.
But the good news are, that we have some additionally days to fix some other issues.

Greetings
Thomas, I18N Team Leader, Zend Framework

Back to top
Sunday
13
July
2008

News on Zend_File_Transfer

Hy interested ones,

the Zend Framework has since today a new file transfer component ready for playing around.

Zend_File_Transfer allows file uploads and downloads when it’s finished.
For now, there is only HTTP POST upload available and it looks like it will be released with 1.6.

The component comes with several validators specially written for validating files with this component.
Below is an example of usage:

The example form looks like this:

<form enctype="multipart/form-data" action="index2.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
Choose a file to upload: <input name="uploadedfiles[]" type="file" /><br />
Choose a file to upload: <input name="uploadedfiles[]" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

The target looks like this:

<?php
require_once "Zend/File/Transfer/Adapter/Http.php";
require_once "Zend/File/Transfer/Exception.php";
	
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setValidators('size', '2000');
	
if ($adapter->isValid() === false) {
    print_r($adapter->getMessages()); 
}
	
try {
    $adapter->setDestination('C:\temp')
            ->receive();
} catch (Zend_File_Transfer_Exception $e) {
    print $e->getMessage();
}
	
print "DOWNLOAD FINISHED!!";

As you see the usage is quite simple.
The seperated isValid() call is not necessary but will show you which failures occured while validation.
Any failure while uploading will also be returned as validation error even when you do not set any validator.

For now there are these validators available:
Zend_Validate_File_Count - validates the file count
Zend_Validate_File_DiskSpace - validates the disk usage of ALL files
Zend_Validate_File_Extension - validates the real file extension
Zend_Validate_File_Size - validates the size of single files

The Zend_Validate_File_Upload validator is the internal validator which checks for upload failures. There is no need to use it as it is automatically used by Zend_File_Transfer itself.

In future the component will be extended with other adapters and also with download capabilities.
I hope you enjoy testing and playing around.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

Back to top