Using Plancake::MailParse library to strip email out of its headers

Due to some issues with composer loading we had to shift our mail parse library from pear::mimeDecode to a more good looking email parse library by Plancake. Just quoting down how we will employ the library to extract headers from an email:
Add the dependancy to your composer.json

    "require":
    {
        "floriansemm/official-library-php-email-parser": "dev-master"
    }

Now in the mail decode class, add this to perform the extraction:

/**
  * Extract headers from the received bounce email using Plancake mail parser
  *
  * @param string $email
  * @return array $emailHeaders.
  */
public function extractHeaders( $email ) {
	$emailHeaders = array();
	$decoder = new PlancakeEmailParser( $email );

	$emailHeaders[ 'to' ] = $decoder->getHeader( 'To' );
	$emailHeaders[ 'subject' ] = $decoder->getSubject();
	$emailHeaders[ 'date' ] = $decoder->getHeader( 'Date' );
	$emailHeaders[ 'x-failed-recipients' ] = $decoder->getHeader( 'X-Failed-Recipients' );

	return $emailHeaders;
}

Now you can have the headers ready in $emailHeaders 🙂 yay!
* The library has no other dependencies and looks neat as a whole. The code can be found here :https://github.com/plancake/official-library-php-email-parser ! Enjoy ! Happy Hacking!

Composer : Loading specific ‘tags’ instead of ‘branches’

The beauty of composer comes to play when we want to have a custom fork of a software, say hosted in Github to be autoloaded. Again, introducing composer to people who are new:-
Quoting from https://getcomposer.org/doc/00-intro.md

Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.

The docs tells exactly how to load a developement branch, using the dev- prefix (https://getcomposer.org/doc/05-repositories.md#vcs)
Problem:
* You want to load a custom release tag version from Github
+ You want to load release tag – 5.0-patch from Github repo of monolg
Solution:
* Edit the composer.json
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/igorw/monolog"
}
],
"require": {
"monolog/monolog": "5.0-patch"
}
}

* save it, run $ composer update
There you go ! 🙂 Thanks

Git: Preparing a release-tag out of an existing stable branch

Just to mention what branches and tag are, A tag represents a version of a particular branch at a moment in time. A branch represents a separate thread of development that may run concurrently with other development efforts on the same code base[1].
Now, last day I hit into a situation of creating a release tag for the WMF cluster out-of the swiftmailer v5.2.0 stable release.
we will use

foo - our repo
v1.2 - the latest stable release tag in a newly created branch foo/1.2

Problem:-
* The source master-branch is buggy, and you want to impress by taking up their latest stable branch (v1.2).
* You want to push some patches into the checked-out (v1.2) branch, and make it a new release-tagged as v1.2-bar.
WorkFlow:-
* clone the local fork of the repo. (If you have write access, the main one itself)
* create a branch starting from the v1.2 tag.
$ git checkout v1.2
you will reach a detached head state
$ git checkout -b foo/1.2
now you are in a new branch foo/1.2 git status to verify that
* now work around the code, fix up the first patch. After committing
$ git push origin HEAD
This will push all the latest branch and commit into the repo. Continue this for all the patches.
Creating a new release tag:
* Now once all the patches are done and pushed into the repo, do
git tag v1.2
git push origin HEAD
bingo! You will have your new tag ready for release :). Thank You
[1]http://stackoverflow.com/questions/1457103/what-is-the-difference-between-a-tag-and-a-branch-in-git