News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
Creating a zip file with PHP's ZipArchive
January 15, 2014 @ 15:40:59

Rob Allen has a new post to his site today showing you how to create a ZIP file with the help of PHP's ZipArchive functionality. The latest versions would need to be installed as an extension (PECL) if they're not already there, but it makes creating the archives a lot simpler.

I recently had a requirement to create a zip file from a number of files created within my application. As it has been years since I last had this problem, I had a look around and discovered that PHP 5.2 has the ZipArchive class that makes this easy. ZipArchive is fully featured, but as I just wanted to create a simple zip file.

All it requires is a few short lines of code - one to open the archive itself, some to add in the files to compress down and another to close and create the file. It's a pretty simple process using this handy extension. Rob also included a bit of sample code showing how to send it out for download with the correct headers.

0 comments voice your opinion now!
zip file archive create tutorial ziparchive

Link: http://akrabat.com/php/creating-a-zip-file-with-phps-ziparchive

Community News:
Laracasts.com - Laravel 4 Screencast Archive
April 17, 2013 @ 11:50:59

A new resource has popped up for those wanting to get even more information about the Laravel PHP framework - the Laracasts.com site. The site is devoted to providing a consolidated listing of Laravel screencasts across the web.

[This site is a] compilation of screencasts from Youtube and Vimeo. Let's learn Laravel together!

There's already a good number of screencasts posted to the site from folks like Taylor Otwell (author of the framework), Jeffrey Way (NetTuts) as well as several recordings of talks from various conferences about the framework. If you have a screencast that's not linked on the site, you can submit the information for review and inclusion.

0 comments voice your opinion now!
laracasts laravel4 screencast archive youtube vimeo sessions

Link: http://laracasts.com

Sebastian Bergmann:
Using PHPUnit from a PHP Archive (PHAR)
October 08, 2012 @ 10:18:52

PHPUnit, the popular PHP unit testing tool, has undergone some changes in its methods of deployment. First it was integrated into the Composer/Packagist dependency management system and now it's been implemented as a phar archive. Sebastian Bergmann explains how to use it in his latest post.

Downloading a single file to use PHPUnit? Not an idea that is too phar out anymore! Starting with version 3.7.5, PHPUnit seems to finally work correctly when packaged as a PHP Archive (PHAR).

He includes a list of steps you can follow to pull down the latest code and use the phar branch that executes with the archive file instead of the local "phpunit" executable. Of course, you can still (as always) install PHPUnit via the PEAR process as well.

0 comments voice your opinion now!
phpunit phar archive tutorial checkout execute


WebSpeaks.in:
Extract the Content of Zip file Using PHP
June 13, 2012 @ 10:44:44

On the WebSpeaks.in site, there's a recent tutorial posted showing how you can extract the contents of a zip file from inside a PHP application.

Sometimes you may want the users on your site to upload the zip file and then check what are the contents of that zip file. In this article I will tell you how to extract the contents of the zip file. I temporarily extract the zip files to a directory and then delete it afterwards. You can chose to keep the extracted content if you want.

The tutorial walks you through the code, showing you how to use their "ZipArchive" class to grab the file, extract the contents and display a list of the "child files" inside it. You can see a live demo of it in action or just download the source and dive right in.

0 comments voice your opinion now!
extract content zip archive list tutorial demo


Till Klampaeckel's Blog:
PHAR and FreeBSD
November 08, 2011 @ 11:51:58

Till Klampaeckel has a new post about replacing the now-missing phar port on FreeBSD installations with a custom compile work-around.

I noticed that archivers/pecl-phar vanished from the ports tree on one of my FreeBSD servers. Problem? Reasons to remove the port were: the port is unmaintained, the port was based on the outdated phar extension from pec and that phar (in pecl) contains open security issues. The simple solution is to create a new port which of course will use the phar which is bundled in PHP's core.

He includes the simple five or six step process you'll need to follow to compile your own phar extension for your installation - grabbing the latest source, compiling (configure/make) and putting the resulting shared object (.so) in the right place for PHP to find it. All that's left then is to enable it in the php.ini. Phar is an archive creation tool that (normally) comes bundled with versions of PHP and can be used to both read and write to compressed packages.

0 comments voice your opinion now!
phar package freebsd compile archive


ZendCasts.com:
Fun with Phar
October 04, 2011 @ 08:14:16

New today on ZendCasts.com there's a screencast tutorial about using phar archives in your applications.

Phar is a new thing that's developed on the horizon over the last few years that's essentially a PHP archive or library.

He shows how to set up a basic application (non-Zend Framework) that does a "hello world" sort of output showing a date "next week". Also included are the commands to bundle it up into a phar archive using the features already built into PHP. The build stub uses the buildFromDirectory and compression/buffering. He also points out a common problem with the default settings on many PHP installed - an INI setting that disables phar creation. Thankfully, it's easy to change via a ini_set call updating the "phar.readonly" setting.

0 comments voice your opinion now!
screencast zendcast archive phar tutorial introduction


Josh Adell's Blog:
Phar Flung Phing
September 26, 2011 @ 10:05:37

Josh Adell has posted about a bit of automation he set up with Phing and PHP's phar packaging to create an archive as a part of his build system. It's a simple five step process mad even easier by the fact that Phing already has a PharPackage task.

One of the cooler features of PHP 5.3 is the ability to package up a set of PHP class files and scripts into a single archive, known as a PHAR ("PHp ARchive"). [...] I decided to see how easy it would be to wrap up Neo4jPHP in a PHAR for distribution. [...] Since I also started playing with Phing recently, I decided to see if I could incorporate packaging a project as a PHAR into my build system. It turns out, it's pretty easy, given that Phing has a built-in PharPackage task.

He points you towards Phing's PEAR channel to get the tool installed and includes a command-line call to update your php.ini to allow PHP to generate phar files. Code is included to create the phar-generation stub as well as the XML for the Phing build file. You can find his end result here.

0 comments voice your opinion now!
phar package archive neo4jphp tutorial build task phing


DZone.com:
Phar PHP libraries included with a single file
September 23, 2011 @ 11:30:40

On DZone.com today Giorgio Sironi has a new post looking at an interesting, if seldom used, feature of recent PHP releases - packaging applications with phar archives.

Phar is a php extensions that provides the means for distributing code as a single archive, that does not have to be extracted to a folder before usage. The concept is similar to JVM Jars: each archive becomes a virtual directory where files can be accessed. However, the virtual folder is not limited to class loading, but you can open and read internal files as if it were decompresse into a directory.

He includes a brief "hello world" example of packaging up a script into a phar archive and executing it via PHP. He also shows how easy it is to create an archive from current code, making an archive containing the latest Doctrine 2 release for simple inclusion. Phars also allow compression and hashing but has issues with resource management and access external files.

0 comments voice your opinion now!
phar archive file compress doctrine2 tutorial


Christian Weiske's Blog:
Working with .phar files
August 26, 2011 @ 09:07:41

Christian Weiske has a new post to his blog looking at a feature of PHP that's very useful yet doesn't seem to be widely used - phar archives. His post introduces you to phar and includes the good and the bad about their use.

It is possible to pack an entire PHP web application up in one single file and run it without unpacking it. This files usually have a .phar extension, which is an acronym for PHp ARchive, loosely based on jar (Java ARchive). [...] With PHP 5.3.0, the Phar extension is an official part of PHP. Shipping your applications as Phar thus is safe since 5.2 has reached its EOL already.

He mentions some of the pros (like one file, no unpacking needed) and cons (like no method for incremental updates, changing individual files inside the package is hard) of using them. He also talks about some of the tools you can use to create your own packages including PHP's own support, phar-util and Phing's phar task. He includes a few "things to consider" when making your packages and gives examples from the SemanticShuttle package to illustrate. Thrown in at the end are some benchmarks that show the difference between static file serving (with and without PHP) and the same sort of statistics with Phar packages included in the mix.

0 comments voice your opinion now!
phar archive tutorial introduction pros cons benchmark


Script-Tutorials.com:
Phar - PHP archiving practice
May 17, 2011 @ 08:28:50

On Script-Tutorials.com today there's a new tutorial showing you how to use one of the more under-used and powerful features of recent PHP releases - the phar packaging for creating self-contained archives.

I guess you noticed that due your project become larger - the more and more files it contain. Sometimes it comes to the thousands of files. And then - Phar can help you. This utility allows us to pack a variety of files in the single library file. Thus, we can significantly reduce the number of include files in the project, and work with the entire library as with single file. It is also possible to have a packed (gzip/bzip2) version of the library.

They show you how to create simple phar archive (sample code here) that contains a few classes linked by an index.php file.

0 comments voice your opinion now!
phar archive tutorial classes



Community Events





Don't see your event here?
Let us know!


list project community laravel developer library framework threedevsandamaybe series wordpress configure release api bugfix interview application code podcast language introduction

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework