A state is known in the law as a jurisdiction and it is absolutely important that your divorce be filed in the correct jurisdiction. If a divorce is filed in the wrong jurisdiction, either by mistake or on purpose, it will be a permanently legally defective divorce forever. It would be as if the divorce were never filed. So, if your divorce is filed in the wrong state and it is mistakenly granted by the judge and, later on, you remarry another person, it is likely you would then be married to that person AND your former spouse! That is called bigamy and is a serious crime.
To file your divorce in a state, you must comply with that state’s residency requirement. To file in Pennsylvania, you OR your spouse must have actually been IN Pennsylvania, going to sleep and getting up, for every day of at least the last six months before your divorce is filed in court. (Of course, if both of you were doing that, that is fine, too.) Having an address in Pennsylvania, owning a home or other real estate, having a Pennsylvania driver’s license, owning a vehicle registered in Pennsylvania, paying a utility bill (like gas, water, electric, telephone or the like) or having a post office box in Pennsylvania does not prove that you have actually been IN Pennsylvania for the required length of time. So, how do you prove it? You must swear to it in writing on the divorce documents under pain of committing a crime. But, remember, one who swears falsely and gets a divorce will not be divorced and that will lead to serious problems if one remarries or dies leaving two spouses behind or is otherwise found to have committed perjury by swearing falsely.
All of that said, if you want to be divorced but live outside of Pennsylvania, you can still file here IF your spouse lives here (and has been here at least six months, of course). Naturally, the spouse who lives in Pennsylvania can file here no matter where the other spouse lives, including in another country. One OR both of you must be a Pennsylvania resident to file your divorce in Pennsylvania and, in either case, either one of you may file the divorce. (There is an exception when a person is in our nation’s full time military service, but I explain that elsewhere in my website.)