From dc01c8bbc18d3545b3caa86b0e0c9ff744d3f8cd Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Thu, 16 Aug 2012 23:57:48 +0100 Subject: [PATCH] Special Feature: (kkamkou) Phar builder script to add phar file as a distribution option --- .gitignore | 1 + Build/build-phar.php | 85 ++++++++++++++++++++++++++++++++++++++ Tests/01pharSimple.php | 94 ++++++++++++++++++++++++++++++++++++++++++ changelog.txt | 1 + 4 files changed, 181 insertions(+) create mode 100644 Build/build-phar.php create mode 100644 Tests/01pharSimple.php diff --git a/.gitignore b/.gitignore index 85df9ce8..7a4478da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build/PHPExcel.phar unitTests/codeCoverage *.buildpath diff --git a/Build/build-phar.php b/Build/build-phar.php new file mode 100644 index 00000000..5e505aa7 --- /dev/null +++ b/Build/build-phar.php @@ -0,0 +1,85 @@ + 'Mark Baker ', + 'Description' => 'A pure PHP library for reading and writing spreadsheet files', + 'Copyright' => 'Mark Baker (c) 2006-' . date('Y'), + 'Timestamp' => time(), + 'Version' => '##VERSION##', + 'Date' => '##DATE##' +); + +// cleanup +if (file_exists($pharName)) { + echo "Removed: {$pharName}\n"; + unlink($pharName); +} + +echo "Building...\n"; + +// the phar object +$phar = new Phar($pharName, null, 'PHPExcel'); +$phar->buildFromDirectory($sourceDir); +$phar->setStub( +<<<'EOT' +getMessage()); + exit(1); + } + + __HALT_COMPILER(); +EOT +); +$phar->setMetadata($metaData); +$phar->compressFiles(Phar::GZ); + +echo "Complete.\n"; + +exit(); diff --git a/Tests/01pharSimple.php b/Tests/01pharSimple.php new file mode 100644 index 00000000..28b527a6 --- /dev/null +++ b/Tests/01pharSimple.php @@ -0,0 +1,94 @@ +'); + +/** Include PHPExcel */ +require_once '../Build/PHPExcel.phar'; + + +// Create new PHPExcel object +echo date('H:i:s') , " Create new PHPExcel object" , EOL; +$objPHPExcel = new PHPExcel(); + +// Set document properties +echo date('H:i:s') , " Set document properties" , EOL; +$objPHPExcel->getProperties()->setCreator("Maarten Balliauw") + ->setLastModifiedBy("Maarten Balliauw") + ->setTitle("PHPExcel Test Document") + ->setSubject("PHPExcel Test Document") + ->setDescription("Test document for PHPExcel, generated using PHP classes.") + ->setKeywords("office PHPExcel php") + ->setCategory("Test result file"); + + +// Add some data +echo date('H:i:s') , " Add some data" , EOL; +$objPHPExcel->setActiveSheetIndex(0) + ->setCellValue('A1', 'Hello') + ->setCellValue('B2', 'world!') + ->setCellValue('C1', 'Hello') + ->setCellValue('D2', 'world!'); + +// Miscellaneous glyphs, UTF-8 +$objPHPExcel->setActiveSheetIndex(0) + ->setCellValue('A4', 'Miscellaneous glyphs') + ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); + +// Rename worksheet +echo date('H:i:s') , " Rename worksheet" , EOL; +$objPHPExcel->getActiveSheet()->setTitle('Simple'); + + +// Set active sheet index to the first sheet, so Excel opens this as the first sheet +$objPHPExcel->setActiveSheetIndex(0); + + +// Save Excel 2007 file +echo date('H:i:s') , " Write to Excel2007 format" , EOL; +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); +$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; +// Save Excel5 file +echo date('H:i:s') , " Write to Excel5 format" , EOL; +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); +$objWriter->save(str_replace('.php', '.xls', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; + + +// Echo memory peak usage +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; + +// Echo done +echo date('H:i:s') , " Done writing files" , EOL; +echo 'Files have been created in ' , getcwd() , EOL; diff --git a/changelog.txt b/changelog.txt index 7537aa5e..845d93fc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -72,6 +72,7 @@ The following methods will be changed in version 1.7.9 Fixed in develop branch: +- Special: (kkamkou) Phar builder script to add phar file as a distribution option - Feature: (MBaker) Refactor PDF Writer to allow use with a choice of PDF Rendering library rather than restricting to tcPDF Current options are tcPDF, mPDF, DomPDF