Software Packaging in 2012

International PHP Conference 2012 | October, 15th | Arne Blankerts

Your Goal?

» Share your code » Distribute a or framework » Release an application » Deploy to a production or stage server » Deploy identically to many servers » ...?

sharing experience Share your code

» You do not need a packaging system » Use a version control system » Get a github.com account ;)

sharing experience Distribute a library or framework

» Pear » http://pear.php.net » Pyrus aka Pear2 » http://pear2.php.net » Composer » http://getcomposer.org

sharing experience Release an application

» Pear » PHP Archive (PHAR) » OS Level Packages » RPM » » ...

sharing experience Deploy to a production or stage server

» Pear » OS Level Packages » GIT

sharing experience The choice is yours.

And depends on your goal. PEAR

» The Legacy Installer » Packages come as .gz file » Package.xml for meta information » Limited Dependency management » Can install depended PEAR packages » Informs on version / extension mismatches » Packages are organized in Channels

sharing experience PEAR - Pirum

» A PEAR Channel Server » http://pirum.sensiolabs.org/ » http://github.com/fabpot/Pirum

» Installed via PEAR

» channel-discover pear.pirum-project.org » pear installes pirum/Pirum

sharing experience Creating a pear package

» Create a package.xml » Build package: » pear package » Add to prium: » pirum add package.tgz

sharing experience Pyrus / PEAR 2

» Rewritten PEAR Installer » Same package.xml » Comes as phar

» Seems to be pretty much a dead project

sharing experience Composer

» Easy to install » curl -s https://getcomposer.org/installer | php » Comes as phar » Makes heavy use of git » And github.com » Packages listed on packagist.org » Limited dependency management

sharing experience Creating a Composer Package

» Create a composer. » Add it to your git project » Get a github.com account » Push your code » Register with packagist.org

» Technically, composer does not exactly create packages

sharing experience GIT

» Not exactly a package either » Can be used for deployment » Create empty repository » Change configuration to a have working directory » Push to ”empty“ repository » Very limited dependency managament » GIT Submodules

sharing experience OS Level Packages

» Distribution specific format and handling » on Fedora/Redhat/CentOS and derivatives » Apt on Debian/Ubuntu and derivatives » Complete dependency management » As long as they are available as distro package

sharing experience Creating RPM packages

» Create an application.spec file » Build package: » rpmbuild -bb application.spec » Add to repository » createrepo directory » Install » yum install package

sharing experience PHAR

» Allows for all-in-one packages » Different file formats possible » Native » Basically a tar-alike format » ZIP Container » No dependency management » All Dependencies should be bundled

sharing experience Creating a PHAR

» Enable PHAR write mode » phar.readonly = 0

» For a library » phpab -p -o library.phar src » For an application » phpab --all -p -o application.phar -t app.php src

sharing experience Manually creating a PHAR package

» Use phar cli application » Use ZIP » Simply rename the .zip to .phar

» Add a stub as needed

sharing experience Anything else? Other packaging options

» Simple tar.gz / tar.bz2 / ... » Windows Installer » Zend Server Deployment

» Other proprietary formats

sharing experience

Contact

» Web http://thePHP.cc/

» Mail [email protected] [email protected]

» Twitter @arneblankerts @thePHPcc

sharing experience