Raspberry Pi with PHP (or Arduino/ESP8266/NodeMCU) to GPIO to Relay to Gate/Garage Trigger

You need a “rule” engine inside of SmartThings.

The simplest one is the one offered by Samsung/ST — called Smart Lighting… go to your SmartApps and just install it.

The old favorite was Rule Machine but the developer of it killed the project and now we have CoRE — comminity’s own rule engine. It’s SUPER-NICE for advanced rules — but for your miniscule requirement of sensor then switch — Smart Lighting should do the trick and I’d highly recommend it given that Samsung fully supports it.