There is no real replacement for onions and garlic (they are so unique in taste). However, here is a Mediterranean trick: use anchovies. Anchovies can be cooked in a bit of extra-virgin olive oil to give a lot of taste to a dish. They melt (yes!) so you won’t find them in the dish, and the taste is actually subtle. Use them as you would use onion or garlic.