PHP Classes

PHP JSON Archive: Create and extract file archives in JSON format

Recommend this page to a friend!
  Info   View files Documentation   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 58%Total: 348 This week: 1All time: 7,000 This week: 256Up
Version License PHP version Categories
json-archive 1.0GNU Lesser Genera...5PHP 5, Files and Folders, Cryptography, C...
Description 

Author

This class can create and extract file archives in JSON format.

It can compose an archive made of individual files or even whole directories.

The archived files are compressed and outputted in JSON format. Archive files may have comments and be protected with a password.

The class can also extract the files of previously compacted archives in the JSON format.

Innovation Award
PHP Programming Innovation award nominee
August 2015
Number 7
JSON has become a format for exchanging typed data structures even between applications written in other languages besides JavaScript.

This package takes advantage of the portability of the JSON format to create portable archives of compressed files that can be created and extracted by programs in any language that support the JSON format.

Manuel Lemos
Picture of Ore Richard Muyiwa
  Performance   Level  
Name: Ore Richard Muyiwa <contact>
Classes: 6 packages by
Country: Nigeria Nigeria
Age: 30
All time rank: 13154 in Nigeria Nigeria
Week rank: 26 Up2 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 3x

Documentation

EXAMPLES ======== $fr = new JSON_Archive; // Adding files to the archive ------------------------------- $fr->add("file.ext"); $fr->add("directory/file.ext"); // Setting a password/key to the archive ------------------------------------------ $fr->setKey("example key"); # You will need to supply this before any read action or write if # the archive is encrypted. // Adding comments and extra stuffs about the file... ------------------------------------------------------- $fr->addComment("This archive consists of two files and requires a password to open it."); // Adding credits and copyrights to the file... ------------------------------------------------------- $fr->setAuthor("My Name"); // Compressing files... ---------------------------------- $fr->compress("outfile" [, true|false]); # NOTE: that the file name is optional and does not necessarily # ends with the .son extension # The second optional argument decides if you want compress to # output a file (true) or not (false). # Default: true // Getting informations about an archive... ------------------------------------------------ $vm = $fr->getHeder("filename.son"); $name = $vm["name"]; # NOTE: If a file name is not supplied to getHeader, it naturally assumes # we are getting headers of the last file we decompressed # or the file we are trying to compress as the case me seem apropriate. # header infos # # name, secure, compressedsize, uncompressedsize, totalfiless, created, # compressionlevel, comments and version. Where version is the version of the # library that performs the compression. (Might be useful to developers). // Adding an entire directory to the archive --------------------------------------------- $fr->addDirectory("example_directory"); // Decompressing an archive -------------------------------- $fr->decompress("filename.son" [, "to_folder", [true|false]]); # The third optional argument decides if you want decompress to # output a file (true) or not (false). # Default: true // Getting information for a file in the archive ------------------------------------------------- $v = $fr->getFilesInfo("example.son"); foreach($v as $key => $value){ echo $key.": ".$value; } // Getting error returned by the class --------------------------------------- $fr->error(); // Renaming a file in an archive -------------------------------- $fr->rename("filename.son", int fileindex, "newnameoffile"); // Deleting a file in an archive -------------------------------- $fr->delete("filename.son", int fileindex); NOTE: fileindex can be derived from getFilesInfo. # E.g. getFilesInfo("filename")["index"]; // Outputing archive JSON --------------------------- One of the advantages of JSON Archives is that they can serve as a server/client file exchange manager. $fr->purify( [true|false] ); Using purify lets you return pure JSON results. NOTE: Unless you explicitly define write as true, purify stops the output stream of compress completely. To return to default, set the an argument false to purify. E.g $fr->purify(false); // NOTE: [ ] refers to optional fields that may be required in // certain circumstances.

Details

Richard-Mcfriend-s-JSON-Archive

A file archive based on the JavaScript Object Notation

  1. High compression ratio.
  2. Simple and lightweight
  3. Support for JSON by many programming language gives it easy implementation and portability.
  4. Saves space consumed by files uploaded to your application.
  5. JSON can easily be manipulated by JavaScript making it serve as a server/client interface when purified.
  6. Serve as a server/client file transfer mechanism.
  7. Secure. JSON Archives can be secured with a password.
  8. Out-performs zip with large files and archive.

CLASS JSON_Archive FEATURES

  1. Compress files.
  2. Decompress Archive.
  3. Rename and Delete files in archive.
  4. Moves files in archive by renaming them.
  5. Get details of files in archive.
  6. Get archive details.
  7. Return archive as JSON string.
  8. Secure archives.
  9. Set compression level between 1 and 9.
  10. Full directory compression.
  11. Add comments and author/owner details.

  Files folder image Files  
File Role Description
Accessible without login Plain text file Examples.txt Doc. Examples
Accessible without login Plain text file How-to-help Data How to help develop JSON Archive
Plain text file JSONArchive.php Class Main class file
Accessible without login Plain text file License.txt Lic. License file
Accessible without login Plain text file ReadMe.md Data Read me

 Version Control Unique User Downloads Download Rankings  
 0%
Total:348
This week:1
All time:7,000
This week:256Up
User Ratings User Comments (1)
 All time
Utility:85%StarStarStarStarStar
Consistency:85%StarStarStarStarStar
Documentation:75%StarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:58%StarStarStar
Rank:1536