2017 © Pedro Peláez
 

library zf-filesystem

Filesystem wrapper objects

image

phpro/zf-filesystem

Filesystem wrapper objects

  • Monday, January 25, 2016
  • by phpro
  • Repository
  • 4 Watchers
  • 3 Stars
  • 870 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 5 % Grown

The README.md

Repository abandoned 2020-11-27

This repository has been archived since we are not using it anymore internally. Feel free to use it AS-IS, we won't be providing any support anymore., (*1)

zf-filesystem

This module contains of:, (*2)

  • a wrapper for filesystem actions
  • a wrapper for files with specific features
  • a metadata layer which makes it possible to query for specific file metadata like IPTC, EXIF, XMP, ...

Installation

Add to composer.json

"phpro/zf-filesystem": "~0.2.0"

Add to application config

return array(
    'modules' => array(
        'Phpro\\Filesystem',
        // other libs...
    ),
    // Other config
);

Configuration

Copy the file config/phpro_filesystem.local.php.dist to the autoload folder of your application., (*3)

Configuration options:

Exiftool - executable: The location of exiftool on your machine - allowed_tags: The tags that can be queried with exiftool. This list is automatically generated, but could be manually overwritten. Check config/exiftool-tags.php for a full list., (*4)

Features

Filesystem wrapper

This module adds the Symfony Filesystem component to the ZF2 servicemanager. By using the FilesystemAwareInterface, the filesystem component is automatically added to your objects by the serviceManager., (*5)

File wrapper

By implementing the FileInterface it is easy and straight forward to pass file objects to custom objects and services in your application. There are already 2 implementations available:, (*6)

  • LocalFile
  • UploadedFile

It is possible to apply certain features to these file objects. For example:, (*7)

  • Moveable

Metadata

This module provides some tools to query for metadata on a file. Following metadata providers are available:, (*8)

General - Md5, (*9)

Images - ExifTool - Identify - ImageInfo, (*10)

Md5:

The MD5 metadata tool provides the MD5 hash of a file and is a wrapper for the php md5_file() command.., (*11)

Usage:, (*12)

$md5 = $serviceLocator->get('Phpro\Filesystem\Metadata\Md5');
$hash = $md5->getMetadataForFile($file, []);

ExifTool

The ExifTool metadata tool provides a wrapper for the exiftool command. It is possible to return all data or specify a specific tag., (*13)

Usage:, (*14)

$exiftool = $serviceLocator->get('Phpro\Filesystem\Metadata\Image\ExifTool');
$meta = $exiftool->getMetadataForFile($file, []);
$meta = $exiftool->getMetadataForFile($file, ['tag' => 'exif']);
$meta = $exiftool->getMetadataForFile($file, ['tag' => 'iptc']);
$meta = $exiftool->getMetadataForFile($file, ['tag' => 'xmp']);

Identify

The Identify metadata tool provides a wrapper for the identify command of ImageMagick. It is possible to ask for the regular information or some extended configurations. Extended configuration consist of:, (*15)

  • spotColors

Usage:, (*16)

$identify = $serviceLocator->get('Phpro\Filesystem\Metadata\Image\Identify');
$meta = $identify->getMetadataForFile($file, []);
$meta = $identify->getMetadataForFile($file, ['extended' => true]);

ImageInfo

The ExifTool metadata tool provides a wrapper for the php getImageSize() command. It is possible to return the regular data or the regular + extended data:, (*17)

Usage:, (*18)

$imageInfo = $serviceLocator->get('Phpro\Filesystem\Metadata\Image\ImageInfo');
$meta = $imageInfo->getMetadataForFile($file, []);
$meta = $imageInfo->getMetadataForFile($file, ['extended' => true]);

The Versions