Preheat oven to 350°F (175°C). Grease a 9-inch pie dish.
Heat olive oil in a large skillet over medium heat. Add onions and cook until translucent, about 5 minutes.
Add garlic and spinach. Cook until wilted and moisture has evaporated. Remove from heat and let cool.
In a large bowl, whisk eggs. Add feta, ricotta, dill, salt, pepper, and cooled spinach mixture. Mix well.
Layer 4 sheets of phyllo dough in the pie dish, brushing each with melted butter. Let the edges hang over the dish.
Pour in spinach mixture and spread evenly. Top with remaining phyllo sheets, again brushing each with butter.
Fold overhanging dough over the top and brush with butter.
Bake for 40–45 minutes, or until golden brown. Let cool slightly before serving.