You need a transit visa in Portugal if you leave the international transit zone and pass through customs.