Post commit to clear cache :D

So whenever you commit you can spot changes or errors of your own. Will save you time.

// .git/hooks/post-commit
#!/usr/bin/env php
system('rm -rf app/cache/*');
system('php app/console cache:clear --env=dev --no-debug');

Githug and Git Achievements are complementary

I have just kind of finished testing githug and git achievements. I believe both tools are useful. One tracks all your git commands that you do throughout the day and the other actually constraints you to work into one directory where you will find git challenges and it at the end prompts you to create your own level which is the interesting part. That of course one can do when one has at least a pretty good level in git. I wonder if there can be a tool like this but able to teach github commands or other. It is interesting how this although it does not replace the theory it does a good deal in the practice and testing side. It teaches by challenging you. I recommend taking a look at both.

What would be a good level to create for PR’eing advanced example or other task like that?

When Your Mate Deletes Your Files On A Common Project

What happens when your friend removes some of your files because he thought it was not needed and then you want to rebase and it is gone. There are several ways to recover the file, by going to github and checking on its history, but here I will present two methods of how to do this. The first one is via a log command and the second is via a rev-list command.

git log --pretty=oneline -- <file_path> | tac

This way we reverse the output of a git log regarding the file in question. But now let’s look at a more interesting way:

git rev-list -n 1 HEAD -- <file_path>
git checkout <deleting_commit>^ -- <file_path>
// or in one command
git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"

In case you also want to review more than one commit you can vary the 1 above to include more commits that have to do with the file in question.

Git Subtree Split: This is what Symfony2 does every night to set standalone Components!

First we need to get the git-subtree project:

~ git clone
~ sudo apt-get install asciidoc
~ sudo make install
~ sudo ./install // just to be sure :D

Now that our tool to do the job is installed it is time to filter all the commits and create our new repository, push to github and then add prehaps a composer to it that can in turn require the other dependency of Config Component.

~ git subtree split -P src/Symfony/Component/ResourceWatcher
~ git checkout ec140481b9e7b7f18aa10516f5da6e43bbaea47a
~ git checkout -b component/resourceWatcher
// from here on you can push to

Now our component is ready to be sourced from any project’s composer.json. Just remember to include also the Config component dependency.
You can find my personal repo at

Update: Thanks to @Stof for this link
They do it this way which makes a lot more sense 😀 and perhaps more git learning oriented:

[tekkub@tekBook: ~/tmp/github-gem master] $ git filter-branch --prune-empty --subdirectory-filter lib master

How to use Composer without Packagist like a Newbie

Say for instance you want to use a bundle from someone else, however that someone has not taken the time to update her repository with a composer.json neither has she taken the time to register her repository in site. You don’t have time to wait for a PR to be accepted and then waiting for the developer to register whenever. So you take the thing in your own hands and register it yourself on packagist within your own vendor namespace? Wrong!

Here is how it is done, this is indeed a real example:

    "name": "symfony/framework-standard-edition",
    "autoload": {
        "psr-0": { "": "src/" }
    "require": {
        "php": ">=5.3.2",
        "symfony/symfony": "2.1.*",
        "doctrine/orm": "2.2.0",
        "doctrine/doctrine-bundle": "dev-master",
        "twig/extensions": "dev-master",
        "symfony/assetic-bundle": "dev-master",
        "symfony/swiftmailer-bundle": "dev-master",
        "symfony/monolog-bundle": "dev-master",
        "sensio/distribution-bundle": "dev-master",
        "sensio/framework-extra-bundle": "dev-master",
        "sensio/generator-bundle": "dev-master",
        "jms/security-extra-bundle": "1.1.0",
        "jms/di-extra-bundle": "1.0.1",
        "cordoval/quizbundle": "1.0"
    "repositories": [
            "type": "package",
            "package": {
                "name": "cordoval/quizbundle",
                "version": "1.0",
                "dist": {
                    "url": "",
                    "type": "zip"
                "autoload": {
                    "psr-0": { "Smirik\\QuizBundle": "" }
                "target-dir": "Smirik/QuizBundle"
    "scripts": {
        "post-install-cmd": [
        "post-update-cmd": [
    "config": {
        "bin-dir": "bin"
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web"

Now make sure you focus on the “cordoval/quizbundle” definition of the bundle. This is directing composer to install the dep from my fork of the bundle on github and not the original main repository one.

Note: When downloading from github or other url, if we instruct composer to do:

composer install --prefer-source

What it will do is to always download the source version of the releases so the source will have .git folder in it. If we don’t tell it and we instruct the version for the package to be different than dev-master then composer will always download the release distribution version which do not contain .git folder.