You use your companion's share spells ability out to a range of 30 feet, rather than the standard 5 feet. You can cast touch spells to affect your companion at a greater range than normal. You can change a spell's range from touch to short (range of 25 feet + 5 feet per two caster levels) if the spell targets only your companion.
You can only share spells with your animal companion when your companion is within 5 feet of you.