A helpful Twig extension – Fetch


Inspired by Symfony’s twig extension to fetch output from external controllers and URL’s in their Twig subsystem, I wrote this small Twig function which you can use in your general twig templates. The main purpose of this extension is to fetch external URL (via GET or POST). You can also pass an arbitrary number of parameters which is helpful while fetching external URL via POST.

Here is the code of the Fetch extension.

To use this newly created extension, initialize your Twig loader in this way

//include the twig extension file first

$loader = new \Twig_Loader_Filesystem(__DIR__ . "/../app/twig"); //change accordingly
$twig = new \Twig_Environment($loader);
$twig->addExtension(new Fetch());
return $twig;

And then you can simply call it in your twig files in this way

{{ fetch("http://yourdomain.tld") }}


{{ fetch("http://yourdomain.tld", {'param1':'value1','param2':'value2'}) }}

And you’ll notice that the output from the URL is now fetched and displayed in your twig output :)

Hope you enjoy this :)


সহজ বাংলায় ডিজাইন প্যাটার্ন: ফ্যাসাড (Facade)

ডিজাইন প্যাটার্ন শুনলেই অনেকেই ঘেমে ওঠেন আর মনে পড়ে যায় গ্যাং-অব-ফোরের দাঁত কিড়মিড় করা ডিজাইন প্যাটার্ন বইটার কথা। তবে মজার বিষয় হল যে আমরা আমাদের নিত্যদিনের প্রোগ্রামিংয়ে অনেকসময়ই জেনে বা না জেনে এসব প্যাটার্ন ব্যবহার করে থাকি, কিন্তু টেকনিক্যাল নাম শুনলে অনেকেই বলতে পারি না যে জিনিসটা আসলে কি। এখন থেকে আমি চেষ্টা করব একদম সহজে কিছু বহুল প্রচলিত ডিজাইন প্যাটার্ন বুঝিয়ে দিতে, আর তারই প্রচেষ্টা হিসেবে আজকের বিষয় হল Facade বা “ফ্যাসাড”

একটু কঠিন বাংলায় ফ্যাসাড হল কোন অবজেক্ট (বা অবজেক্টসমূহ) আরও সহজে ব্যাবহার করার জন্য কুইকলি কোন ফাংশন বা আরেকটা অবজেক্ট লেখা, যার ফলে ব্যবহারকারী কষ্ট না করে অনেক সহজে সেই অবজেক্ট (বা অবজেক্টসমূহ) ব্যবহার করতে পারবেন।

এবার চলুন সহজ বাংলায় বুঝি ফ্যাসাড কি Continue reading


থিমফরেস্টে ওয়ার্ডপ্রেস থিম পাবলিশ করার আগে একটা প্রয়োজনীয় চেকলিস্ট


অনেক কষ্ট করে এবং সময় ব্যয় করে একটা ওয়ার্ডপ্রেস থিম তৈরী করে তারপর হার্ড রিজেক্ট বা একের পর এক সফট রিজেক্ট খেলে দেখা যায় অনেকেই কনফিডেন্স হারিয়ে ফেলেন। তাদের জন্য আজকে আমার ছোট্ট এই চেকলিস্ট যাতেকরে প্রয়োজনীয় কাজগুলো আগেই ঠিকমত করে রাখতে পারেন এবং রিজেকশনের সম্ভাবনাও কমিয়ে ফেলতে পারেন

১. ভ্যালিড মার্কআপ লিখুন। মার্কআপ যদি ব্রোকেন হয় তাহলে সেটা রিজেক্ট খাওয়ার সম্ভাবনা শতকরা ৯৯ ভাগ
২. ডিজাইনে বৈচিত্র আনতে হবে এমন কোন কথা নেই, জাস্ট আপনার কাজ যেন সব ব্রাউজারে ঠিক মত চলে সেদিকে লক্ষ্য রাখুন।
৩. টাইপোগ্রাফি এবং কনটেন্টের বিন্যাস খুবই প্রয়োজনীয় একটা বিষয়। এই বিষয়ে অভিজ্ঞ হবার জন্য নতুন বা অ্যাপ্রুভ হওয়া থিমগুলো বেশী করে দেখুন। খুব বেশী এলিমেন্ট দেয়ার চেয়ে বরং আকর্ষনীয় ভাবে উপস্থাপন করাটা বেশী জরুরী Continue reading


SupportX – A rich support app-theme for Envato Authors built using WordPress

01_supportx_preview.__large_preview (1)
Last week, we have developed SupportX, a beautiful support theme based on WordPress. SupportX is built specially for the Envato marketplace authors where it’s a tedious job to provide proper support to the buyers of their product. It comes with a handful of useful features like SMS notification, live notification feed, purchase code verification and Knowledge base, and it doesn’t require to install external plugins like bbPress to use SupportX.

For $45, I must say that it’s a real bargain. You can purchase SupportX from Themeforest by going to this link http://bit.ly/1o90Wvc


With 1.1GB/s IO, Ramnode is possibly one of the best VPS providers out there

When you search for low end boxes, you may think that services are not up to the mark with these providers. Guess what, You are WRONG, so WRONG indeed. There are a few providers who gives you a top class services, despite their price point.


I have been using Ramnode for almost 6 months by now, had used Rackspace and Amazon EC2 before and I am not a big fan of them except the instant resource modification feature. When I purchased my first box from Ramnode, I was just thinking let’s give a try. And once I started, I totally loved their services. From 1Gbit network to an amazing RAID10 setup that gives you upto 1.3 GB/s in SSD and 800MB/s in SSD Cached VPSes. Here is the result of dd test in one of my SSD boxes.

d if=/dev/zero of=iotest bs=64k count=16k conv=fdatasync && rm -rf iotest
16384+0 records in
16384+0 records out
1073741824 bytes (1.1 GB) copied, 1.01694 s, 1.1 GB/s

and here is the result from one of my SSD cached boxes

dd if=/dev/zero of=iotest bs=64k count=16k conv=fdatasync && rm -rf iotest
16384+0 records in
16384+0 records out
1073741824 bytes (1.1 GB) copied, 1.37957 s, 778 MB/s

Ramnode has been a great provider to many people out there for last 2 years, and several time won the quarterly poll arranged by LEB community. Give it a shot anytime without worrying much, you won’t be disappointed. And beside enjoying such a great servcie, enjoy an additional discount of 38% by using the coupon code WOWNUM1 for any of their plans.


Integrate Social Sign On in your PHP apps using HybridAuth


Integrating social sign-ons in a web application can become a tedious task because you need to take care of different endpoints, credentials and finally manage the oauth dance to get the access token. However, using HybridAuth package, this task can be easy as pie :) Let’s have a look

In this example I will show you how to connect to Facebook and Twitter using HybridAuth. So you need to create two applications in Facebook and Twitter each. Save those app’s id and secret somewhere because we will need that in a minute.

Step 1: Install the Package via Composer

Composer is an excellent package manager for PHP apps. Let’s use that to install HybridAuth in our current projects scope. Add a composer.json file in your project path, or update it with the following contents if it already exists. But before that, make sure that you have composer installed in this machine.

    "require": {
        "hybridauth/hybridauth": "3.0.0.*@dev"

now run the following command to install hybridauth

composer install

Step 2: Connect with Facebook

Let’s make a good use of this HybridAuth. This time we need to create two files, fb.php and hybrid.php. Make sure that your facebook app’s callback url points to this hybrid.php. FOllowing is the code of fb.php Continue reading


Automated Rsync – without compromising security

Rsync is one of the most popular tools to synchronize data between two computers, and used mostly in taking backups using this sync feature. It’s easy to use and only uploads the changed files when a sync is necessary, so it’s effective in saving bandwidth and time too. To run rsync, you need root or a properly privileged user which can access that specific path in the remote machine. And to setup this privilege, you can either use a should-never-be-used root account or an user chrooted using a jail shell. But if, by any chance, current machine is compromised then remote machine is compromised too. Because anyone can connect to your remote machine using those credentials from the current machine. To avoid plain text credentials (or the credentials written in a shell script), people usually use ssh keys to establish a connection between two machines. Still, your remote machine is unsecured if anything goes wrong in the current machine from where you’re taking the backup.

So a fullproof solution is to use ssh keys and properly chroot the remote user so that it can only access the backup files and nothing else. However, setting up a jailed shell is a not-for-everyone type task and takes time and experience to accomplish properly. So here is a quick work around that you can implement in your remote machine to prevent the connecting user from doing anything malicious but only tasks those are needed to perform the rsync backup. Let’s see how we can do that

Before continuing, let’s name our two machines. The one which should be backed up, lets name that Workstation. And the one which is storing the backups is BackupServer. Also for now, let’s assume that you are backing up complete “/var/www” folder in the WorkStation.

Step 1: Create SSH key in the BackupServer
Log into the BackupServer and run the following command in ssh terminal. But remember, if you already have a key in ~/.ssh/id_rsa.pub then IGNORE IGNORE IGNORE this step.

ssh-keygen -t rsa

It will prompt for a passphrase, REMEMBER to just hit the enter without typing anything.

Step 2: Display and Copy the SSH key from BackupServer
Run the following command to display the ssh public key in the terminal, and then copy it.
Continue reading


BucketAdmin – Our new dashboard for your next web application


If you are a fan of beautiful dashboards and admin panels, then BucketAdmin might be a good choice for you with plenty of carefully selected javascript controls and plugins. Beside that, BucketAdmin’s documentation and clean structure will help you to implement it without a lot of pain. Purchase BucketAdmin today for $21 only from http://bit.ly/1e9TtGP.

Here is a collection of a few cool features of BucketAdmin

BucketAdmin Features


WordPress Plugin Boilerplate Code Generator from Tom Mcfarlin’s Plugin Boilerplate

Tom Mcfarlin has written an excellent boilerplate for plugin developers. It is very easy to start writing your own plugins using his boilerplate. But if you want to personalize it to YourPluginName, you will have to modify all these files and replace hardcoded variables and class names which is a real pain in the ass.

So I have created a code generator which takes Tom Mcfarlin’s repository and replace everything (wherever necessary) by your plugin name, author name etc and personalize it so that you can download and start using it right away.

Check out this code generator at http://codegen.kickapz.com

You can download the source code of this code generator at https://github.com/hasinhayder/plugin-boilerplate-code-generator

Writing a new plugin is now painless :)


Create personalized phar files in PHP

Created a screencast to show how you can create phar files, most importantly personalized phar files to store some information inside it and protect it using user’s password. Those information is usable only when user providers a correct password.

For packaging, I used http://box-project.org which is an excellent phar packager. I’ve also used two functions from Josh Hartman’s blog to encrypt and decrypt data using Rijndael algorithm.