Food processor! Does a great job, just pulse it so that it doesn't turn into puree.
You need electric grinder to grind onions and garlic. The blade in the grinder do this trick for you. Garlic is many times saved in freezer for future use.