Skip to content

Instantly share code, notes, and snippets.

@dmitrydyomin
Created April 26, 2018 08:19
Show Gist options
  • Save dmitrydyomin/fbc15af2672d1f168ccaa362bfddc616 to your computer and use it in GitHub Desktop.
Save dmitrydyomin/fbc15af2672d1f168ccaa362bfddc616 to your computer and use it in GitHub Desktop.
PHP dev server script with SSH tunnel
#!/bin/bash
DB_HOST=...
if [[ $1 == --tunnel ]] || [[ $1 == -T ]]; then
ssh -NL 3306:127.0.0.1:3306 $DB_HOST &
PID=$!
echo "ssh pid: $PID"
fi
export APPLICATION_ENV=development
cd public
php -S 0:8000
if [ -n "$PID" ]; then
kill $PID
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment