Creating Plugins for Croogo

Bake a Plugin

To bake a plugin for Croogo, go to Croogo’s app folder in terminal and type following command. Let’s create a plugin named Library.

~/public_html/croogo$ Console/cake bake plugin Library

You will be asked to choose a location of the plugin. Select outermost Plugin/ folder. Above command does following things:

  1. Creates proper directory structure for new plugin
  2. Creates plugin’s AppController.php file (LibraryAppController.php)
  3. Creates plugin’s AppModel.php file (LibraryAppModel.php)
  4. Adds entry in Config/bootstrap.php file to load newly created plugin

It is recommended that you delete entry of newly baked plugin from Config/bootstrap.php file as you will be able to enable-disable plugin from UI. The line will look something like:

CakePlugin::load('Library', array('bootstrap' => false, 'routes' => false));

Configure Plugin to enable – disable

To make plugin available to be enabled – disabled from admin user interface, you will need to edit plugin.json file. This file will not be present in newly created plugin so you can copy this file from Example plugin already present in Croogo.

~/public_html/croogo$ cp Vendor/croogo/croogo/Example/Config/plugin.json Plugin/Library/Config/

And edit this config file with information of your plugin. After creating this file, you should be able to enable-disable plugin.

Add Menu for Your Plugin

Croogo has a CroogoNav() class which is used to add and display menus. It has static functions CroogoNav::add() and CroogoNav::items() that you can call from anywhere in the app. For our plugin, we will add entries for new menu in plugin’s bootstrap.php file. If this file is not present in your Plugin’s Config folder, you can create a new Plugin/Library/Config/bootstrap.php file and write entries for menu there.

Bake Controllers, Models and Views

Before we begin to bake controller, model and view for our plugin, let’s first understand the structure of our plugin. We are trying to create a simple plugin where we should be able to record entries of Books and their Authors.

We will create two tables, one for each Books and Authors and then will create their controllers, models and views. If you understand CakePHP associations – Book belongsTo Author and Author hasMany Books.

  `title` varchar(100) NOT NULL,
  `description` TEXT DEFAULT NULL,
  `author_id` int(11) NOT NULL,
  `created` datetime DEFAULT NULL,
  `created_by` int(20) DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `updated_by` int(20) DEFAULT NULL,
  PRIMARY KEY (`id`)

  `name` varchar(100) NOT NULL,
  `created` datetime DEFAULT NULL,
  `created_by` int(20) DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `updated_by` int(20) DEFAULT NULL,
  PRIMARY KEY (`id`)

Okay, let’s start baking them by using CakePHP bake utility.

$ Console/cake bake model -p Library Author
$ Console/cake bake controller -p Library Authors --admin --public
$ Console/cake bake view -p Library Authors

$ Console/cake bake model -p Library Book
$ Console/cake bake controller -p Library Books --admin --public
$ Console/cake bake view -p Library Books

Testing, testing

Congrats, you have now created your Croogo plugin. You can check the plugin from by logging in to admin. You can start further changes by directly editing files in your Croogo Plugin.


Much of the part is taken from the following video created by Rachman Chavik.

If you find this useful, please share. If you have any suggestions, questions please leave a comment.

Notes on AngularJS

Personal notes on AngularJS
Personal notes on AngularJS

CakePHP Date-time to AngularJS date time

CakePHP created and modified dates are in format “Y-m-d H:i:s” where AngularJS expects date to be in unix format to be able to format.

Using UnderscoreJS with AngularJS

I have used underscoreJS earlier and I must say that it is an awesome plugin that I mostly use wherever I need to deal with lot of JavaScript. This question on Stack Overflow shows you how you can install it with your AngularJS project.

Sharing code between controllers

Initially, I struggled finding what could be a proper way to share common functionality in AngularJS. For example, I was using multiple controllers in my app and I wanted a common place to show error, success, info messages at one place.
This could be achieved in AngularJS by sharing a service.

Loading Bar

I wanted to use a loading progress bar, something similar used on YouTube. Finally I found a plugin, Angular Loading Bar, that calculates correct progress time based on simultaneous HTTP requests and works fine with AngularJS project.

Notes On Setting LAMP Environment For Web Development On Ubuntu

Most of the time I come across situations where I need to install or configure LAMP environment for web application development. I have done this many time but there are always some things that I need to struggle with.

There are plenty tutorials and articles already written on these, but I needed some kind of notes that will suite my development style, and that I can update as I learn new things. So here I am documenting common things related to web application development environment setup. Expect them to be updated over time.

Installing Ubuntu OS

Ubuntu is my favorite operating system and it does my all jobs. Long ago I had written an article on Why should you use Ubuntu. I would like to share some of things that I learnt over time.

Size of Your Swap Partition

While installing Ubuntu, keep a simple thumb rule for swap partition size. Ubuntu community documentations suggests that size of swap partition should be of same size as your RAM.

Create /home directory in separate partition

When installing Ubuntu, create a separate large partition as your /home directory. This partition will contain home folders of all users. The benefit of creating separate partition for /home directory is that you data will be separate from your Ubuntu installation.

For unfortunate reasons, if your Operating System gets corrupt, your data and settings will still be available to you even after formatting and installing your OS partition. Only remember to select the same partition as your /home when re-installing Ubuntu.

Size of OS installation partition

There is no fixed rule and requirements, but I found that 20 GB is good enough and my preferred size is 30 GB. I have never run out of space with this.

Installing LAMP

Quickest way to install LAMP on Ubuntu

Over last few years, I have tried different ways for installing LAMP applications. Many times, I had installed each application separately. During my trial and error learning period, I had to struggle doing many configurations and settings. But I can now set up my environment in very less time.

Essential Software

sudo apt-get install tasksel
sudo tasksel install lamp-server
sudo apt-get install phpmyadmin

If you want to install them manually one by one, you can follow instructions on Ubuntu community documentation for Installing Apache, MySQL, PHP.

Optional Software

Sublime text is my favorite text editor. Ubuntu comes with Firefox pre-installed as default browser. However I prefer Google Chrome. Also when you are working in team, we need to access each other’s machines. SSH is the simplest way we can access other machines and OpenSSH is a application you will need.

# Sublime Text 3 
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

# Google Chrome
wget -q -O - | sudo apt-key add - 
sudo sh -c 'echo "deb stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update 
sudo apt-get install google-chrome-stable

# Open SSH
sudo apt-get install openssh-server

Create Separate Development Environment for each user

As time goes on, number of projects increases in public_html folder. Also there might be multiple users using the same machine for development. It’s good idea to keep things separate.

# Create public_html folder in your home directory
mkdir public_html

# Create symlink in /var/www folder
cd /var/www
sudo ln -s /home/rakesh/public_html rakesh

Now each project folder (project-folder) kept in public_html folder will be available on server as http://localhost/rakesh/project-folder

Quick Notes on User Groups and Permissions

In my opinion this section deserves some attention. Most of the live servers where actual projects are uploaded have Apache server installed. Apache server have it’s own user, ‘www-data’ executing all PHP scripts. It is assumed that ‘www-data’ user owns your PHP files or have permissions to execute, read or write.

On live server, you may not need to do any changes. At the most changing ownership of project folder to ‘www-data’ would be sufficient. But if you are experiencing problems for only some part of your application, such as uploading files, you will need to check permissions correctly.

On our local server, we need to take care that permissions are right. Solution is very simple. First you need to add yourself to group ‘www-data’ and then change permission of your public_html or project folder.

# Add your self to group www-data
sudo adduser your-username www-data

# Change permission of your project folder or all projects
sudo chown -R your-username:www-data /path/to/public_html/or/project/folder

Above solution was partially inspired from this discussion on Ask Ubuntu site to suit above development environment. Here the main difference is we are giving ownership to ‘your-username’ instead of user ‘www-data’. It allows you to create new files without any restrictions and group ‘www-data’ allows you to use those files for other server tasks.

Configuring Apache

Enable Rewrite Module

Almost all PHP applications I have used, requires Rewrite module to be enabled. This is just a one command task.

# Enable Apache Rewrite Module
sudo a2enmod rewrite

You can remember above syntax like “Apache version 2, please ENable MODule named REWRITE“.

Allow .htaccess files to override settings

Most of the project uses .htaccess files to override default server settings. By default .htaccess files cannot override default apache server settings. To allow override, we need to edit default configuration file.

# Go to Apache's sites-available folder
cd /etc/apache2/sites-available/

# Create a backup of original configuration file, will create default.backup file
sudo cp default{,.backup}

# Edit default file and replace all AllowOverride None with AllowOverride All
# your-editor-name (subl|vi|gedit)
sudo your-editor-name default

# Restart apache
sudo service apache2 restart


If you like it, please bookmark and share. If you think I should add something to above post, please changes in comments.

Running WordPress Blog From CakePHP

WordPress and CakePHP together
WordPress and CakePHP together
If you are CakePHP developer, you probably know that files and folders located at app/webroot directory, are visible from urls directly. For example, if you keep example.pdf file in your webroot directory, you can access it from

This logic was earlier used to add wordpress blog to CakePHP. All you had to do is, copy your wordpress folder (renamed to ‘blog’, most of the time) in your webroot directory, so that blog can run from You might need edit .htaccess files to suit your server settings.

I tried above method, and tried various .htaccess settings, but nothing worked with server settings that I use. The issue that I remember where I stopped was that I had to make sure that there’s always a forward slash after word blog. So /blog wasn’t working as expected.

Finally the solution that worked for me is to not keep the blog directory in webroot folder. Instead, I moved it to the same folder where my ‘app’ folder stayed. Additionally I had to write two lines to tell CakePHP that not to consider blog/ at all.

Always Use References In Commit Messages

Make a rule to always add an issue first and then refer it with #number in your commit message. It very easy to ignore this thing. For every small/big change adding a reference might look like extra work. But doing so is really worth.

The real benefit of adding references to commit messages becomes apparent when you are looking for all the changes that were done for particular feature. If you are developing on Github or using project management software like Redmine, these references becomes links to the issue.

How To Share Website Links Instantly And Keep Their Record

When you surf on internet, many times you come across information that is valuable to you or someone you know. You like to share things and that’s why you use Facebook, Twitter or Google+, don’t you?

Sharing Is Caring, Don’t Be Slow

There are different types of information people like to share with different people like a link worth sharing (Twitter), fun to watch video (Facebook), work related (LinkedIn), read it later/bookmark (delicious, Google Reader), related to friend (Gmail) and so on. It’s a time-consuming process if you go to website, log in and copy or type the information every time you want something to share.

Save Your Links and Save Your Time

Share links easily from browserUsing tools like Shareaholic you can save your valuable time in sharing information. Shareaholic is available as extensions and plugins for all popular browsers. It is fast, easy to customize, lightweight, available at a single click on your browser, no adware or spyware.

Shareaholic website also keeps a record of information you share anywhere on the internet. It means that the information you shared to others is also available to you at a single place, when you need it.

FreeMind – A Mind Mapping Software for Productive Brain

There are many ideas that come in our mind but it’s very difficult to collect them at one single place with rapid speed. I have tried different applications to take out ideas out of my mind, but even today I find FreeMind mind mapping application as useful as it was.

What is Mind Mapping?

Mind Map created by FreeMind
FreeMind is a free mind mapping software application build for productivity. FreeMind helps you quickly express your ideas, notes and information on single document with very rapid speed.

With the help of FreeMind you can start with an idea and keep adding related ideas to it just like tree diagrams. But it is much more than a tree diagram. It helps you to link any document, application or website.

The speed of creating mind maps is an important thing, because it not only helps you think faster but also helps you think in a logical and keyword specific way. This way you can grow the idea you are thinking on.

How It Helps Improve Brain’s Performance?

Our mind loves images than pure text. It love colors, graphics and correlations. This is a major reason most of the memory improvement techniques uses link methods, students are advised to create colorful notes and studies say that people remember pictures more than the paragraphs.

FreeMind helps you by allowing you to use correlations, graphics, colors, different fonts, power of HTML to create stunning notes, presentations, essays, blog posts, speeches, and much more.

Are They Socially Sharable?

Yes. A big Yes. You can create stunning mind maps and export them to common document formats Open Office Document (hence MS Word), PDF, images like PNG, JPEG, SVG. You can also directly convert them to HTML, XHTML with JavaScript, XHTML as clickable map or JAVA Applet, even as a Flash!

There are also other applications available that does similar work, but you either need to buy them or they seriously lack important features. FreeMind is a Free tool that worth using.

Other Mind Mapping Software

FreeMind is not one of it’s kind of software but there is a long list of free as well as commercial mind mapping Software you can try out. If you liked the concept, you can visit Wiki Mind Map website to get largest collection of free mind maps that you can download to FreeMind files.

Accessing GMail, Google Docs, Google Calendar Offline

There are many tools that helps you write your emails offline and send or sync them when you are online. These applications are mostly desktop applications. Google availed this ‘offline’ functionality in browser with the help of Google Gears but for the sake of HTML5 and the improving technologies, they have now introduced this feature as Google Chrome extension.

offline gmailI am sure that sooner or later Google will make it available to all HTML5 supporting browser. Currently this only available as Chrome extension. You can install this Offline GMail Chrome extension and experience it yourself.

Just like any other application in the world, it is not so perfect right now. It’s design is simple enough to run on most computers, tablets or smart phone, but it is a great help for those who are not online 24×7.

7 Reasons Why Should You Join and Actively Participate In JUG Nagpur

JUG Nagpur - Java 7 Launch PartyYesterday, I attended Java 7 launch party by Java User Group Nagpur. As it was my first User Group event, when I entered, I was just a curious guy. But as the event came to an end, we all understood how important this group is for both who are learning as well as expert in Java related technologies.

I know how it feels when in the middle of the project, unknown problems you never thought about pops up, when the books do not have all the answers and  Google cannot search it for you. As a developer you and I go through these situations and all you need to do at such situations is to ask your friends from User Group who are ready to help.

Hey, that’s not all. There are more reasons to join JUG Nagpur.

Real world knowledge

What you cannot learn from books, you learn from people. The mistakes you are going to do, might have already done by someone, you can learn from other’s mistakes. And it can only happen when you come and meet real people, share what you think and help each other.

You learn what “book” cannot teach

We all read books to learn programming, but after a certain level of knowledge, you no longer need books to solve complex problems. The projects you work on are based on real world logical complexities. And naturally we all face difficulties at one point or other. A User Group is a great place to look out for help.

Networking with industry peers, make new friends

When you meet people who are better and more experienced, you start learning something. When you meet people less experienced than you, you start using your knowledge and expertize. In JUG Nagpur you meet with all types of people. You learn and let others learn at the same place.

Finding Solutions – More Effectively

Oh yes. There is a saying, “Never reinvent the wheel”. This means you don’t need to make same mistakes other have already done, you don’t need to solve problems that are already solved. All you have to do is just ask your other JUG Nagpur members.

Job Opportunities

When you meet people from different background and experiences, it is likely to boost chances of letting people know about you. When you ask or answer questions, people know about your knowledge. Even if it doesn’t guarantee your job, it helps spread your curiosity to learn and expetize too.

Sharing Experiences

Java User Group Nagpur (JUGNagpur) is a place where you will find people who made it big in their career and people who are just beginning their career. It can add immense value to your career by sharing thoughts with people who spent years in the field and/or worked with giant companies.

You Get A Free T-Shirt

Only if you are lucky enough, you get free gifts like we all got t-shirts at yesterday’s JUG Nagpur events. It’s written on the tee, “Moving JAVA Forward” and so I am. Are you?

If you have not yet joined JUG Nagpur, it’s time to do now! Just visit JUG Nagpur Google Group Page.

Always Updated Guide to Facebook Privacy Problems And Security

Guide to Facebook Privacy Problems and SolutionsCurrent problems with the Facebook Privacy settings is that Facebook do not let you opt-in any of it’s features to you. Most users also complain that Facebook also updates their features without even asking users first.

Some people think, Facebook applications are very annoying and unnecessary. No doubt, there are plenty useful Facebook applications available but many applications are a threat to security and might annoy your friends.

Whatever the situations is, it might be difficult to live without Facebook. The only option we left with is to maximize the privacy with available options.

Read full updated Guide: Always Up-to-date Guide to Manage Facebook Privacy.