Here is all that you need to know in order to invite your immediate family to live with you in Spain and be granted a spanish residence permit before visa expiration.
Foreigner in Spain with at least a temporary Spanish residence permit of two years can apply for the Spanish residence permit for his/her immediate family back home in order to reunite with them here in Spain. The foreigner already here in Spain must have legally resided in Spain for at least one year and must have the authorization to legally reside for at least another one year. And he should have a made ready accommodation for the immediate family that he/she is inviting over. And should be able to boast of enough income to take care of his/her invitee. If all necessary conditions have been met, a Spanish residence permit will be authorized to the immediate family you are bringing over with the same duration of validity as that of the family already residing here in Spain who is making the invitation.
These are just the major things that will qualify you to regrouping with your immediate family here in Spain. But because of the constant changes in the law of the land, it would be advisable to consult a good lawyer here in Spain to help you carry out the process as by virtue of his/her profession would know better. So long as you meet all the requirements mentioned above.