-
Notifications
You must be signed in to change notification settings - Fork 11
Installation
This tutorial guides you through the installation of Morph
- The Morph package requires a a recent version of PHP (5.3+)
- The MongoDB PHP driver - see this wiki page for more details
- Morph itself! You can either download a copy from the morph github page, or better still fork it.
##Building Morph.phar Morph makes it super easy for you to integrate itself into your projects by allowing you to build a self contained PHP Archive (Phar file). There are several ways to build the Phar:
###Building using make_phar.php
This is the easiest way. All you need to do is ensure that phar.readonly is set to 0 in the CLI version of your php.ini file (on Ubuntu this file is located in /etc/php5/cli/php.ini), and it will generate the Morph.phar file for you in the same directory as the script. make_phar.php is in the root directory of the source code, outside of src.
###Building using Phing
This is the harder way, but once you get it set up it becomes as easy as the make_phar.php script. You will need two things:
To install these, you need to make sure pear is installed and upgraded to the latest version (requires root). On ubuntu, pear is included in the php5-pear package
sudo apt-get install php5-pear
pear upgrade pear
Install some prerequisite packages for phing and phpunit (requires root):
pear install pear/XML_RPC2
pear install PhpDocumentor
To install phing: (these need to be run as root, so use sudo / su as needed)
pear channel-discover pear.phing.info
pear install phing/phing
To install PHPUnit, you first need to install some packages for php, php5-curl and php5-xsl. (These commands are for ubuntu, but the package names should be similar for other distributions / Operating systems)
sudo apt-get install php5-curl
sudo apt-get install php5-xsl
Then you install the pear packages (these also require root access, use sudo/su as needed)
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install phpunit/PHPUnit
You will also need to modify your php.ini file to enable writing phar files (normally disabled by default) by adding the line: (NOTE: THIS NEEDS TO BE THE CLI VERSION OF THE php.ini FILE, on ubuntu this is located in /etc/php5/cli/php.ini)
phar.readonly = false
Now you are ready to download the source and compile the Morph.phar package.
Download the source and build it using phing:
sudo apt-get install git
mkdir code
cd code
git clone git://github.com/a-musing-moose/morph.git
cd morph
phing package
Now you should have a Morph.phar file inside the morph directory. Place that wherever you want and use it in your php code!
To make use of Morph.phar you need to install the Phar extension. The phar extension is included in the standard distribution of PHP 5.3+.
The phar file contains everything you need to get up and running, acting like a shared object or dll. All you need to do is require the phar file before you use the library. e.g.
<?php
require 'Morph.phar';
//keep calm and carry onMorph is designed to work in conjunction with an Autoloader that maps classes to files and folders. e.g. \morph\Query should map to include-path/morph/Query.php
The Morph phar file already includes such an autoloader but you can easily implement your own one or use the more manual require/include option if you wish. Morph should also work with the Zend Framework autoloader.