4 tablespoons (1/2 stick) butter, plus softened butter, for the baking dish
5 to 6 medium russet potatoes
1 teaspoon salt, or to taste
Freshly ground black pepper
4 cloves garlic, finely chopped
1 medium onion, finely diced
One 8-ounce package cream cheese, at room temperature
1 cup half-and-half
2 tablespoons minced fresh rosemary
3 green onions, light green and medium green parts, thinly sliced
1 cup grated Parmesan
Preheat the oven to 350 degrees F. Rub the bottom of a 9-by-13-inch baking dish with softened butter.
Using a mandoline or a very sharp knife, slice the potatoes very thinly. They'll cook better that way. Place the potatoes in the baking dish and sprinkle with 1/2 teaspoon salt and some pepper.
In a large skillet over medium-low heat, melt the butter. Add the garlic and onions and cook until translucent, stirring occasionally, about 4 minutes. Cut the bar of cream cheese in half and add the halves to the skillet, stirring constantly. Continue stirring until the mixture is smooth and combined, about 3 minutes. Pour in the half-and-half and stir to combine. Mix in 1/2 teaspoon salt and some pepper. Taste and adjust the seasonings as necessary. Do not undersalt! Add the rosemary and green onions and stir to combine. Finally, mix in 1/2 cup of the grated Parmesan.
Pour the cream cheese mixture over the top of the potatoes. Scrape out the skillet to get every last drop. Sprinkle the remaining 1/2 cup grated Parmesan generously over the top and bake until golden brown and bubbly, at least 1 hour. Let stand for 10 minutes before serving.