For defending your base against alien invasions (which are a good thing when they bring a big UFO for you to dismantle later), here are some general principles for building placement, which you have to bear in mind from when you start the base:
1. Try to have the buildings that aliens enter the base from, all together at one side of the map, and only joined to the rest of your base via one building. This creates a bottleneck or choke point through which aliens have to come to get to the rest of your base.
The buildings that aliens enter through are: The entrance ramp, the drop ship hangar, the workshop, and very rarely the standard radar (I have not build advanced radar so I don't know about that).
2. The standard radar building has a tower sticking above ground which makes a good sniper's nest to snipe aliens on the surface. I like to make the radar the choke point building and place it near the entrance buildings so that I can send a sniper up the tower to provide enfilade fire on aliens milling around the entrances of the other buildings. The drop ship hangar also has a tower that you can snipe from but the hangar roof blocks a lot of the field of fire from it so it is not that useful.
3. Try to put buildings with no above ground structures, or low above ground structures that will not block your fields of fire from the radar tower. These buildings have low or no above ground parts: antimatter storage, hospital, alien containment, command centre. Build these near your radar tower, and those with higher above ground bits further back so they will not block your fire from the tower.
4. The Phalanx soldiers will spawn mostly in the command centre, with a few in the accommodation blocks and hospital. Build the command centre close to the choke point (radar building in my case) so you can quickly concentrate your forces there. The command centre also has not too much stuff above ground so it will not block your sniper fire from the radar tower. The accommodation blocks have big above ground rooms so be careful where you put them. If you have guns that can shoot through walls (bolter, coilgun), you can also do some limited sniping through the walls of some of the above ground accommodation rooms, and also the interceptor hangar.