Collection of small tools that provide additional features when developing websites using DevKinsta.
cd ~/DevKinsta/private
git clone https://github.com/stracker-phil/devkinsta-tools.git .
All scripts should be placed inside your DevKinsta/private
folder. That location is shared with the Docker container devkinsta_fpm
.
Call scripts from the command line, i.e. from the Terminal app on macOS; possibly they also work inside the Windows 10 Command Prompt (cmd.exe
).
For example, to setup Xdebug:
cd ~/DevKinsta/private
bash setup-xdebug.sh
Here is a short overview of the scripts and what they can do for you:
Need
--help
?Use the param
-h
or--help
on any script to display usage details and notes.
For examplebash wp-cron.sh --help
orsite.sh -h
bash setup-backups.sh --help
bash setup-backups.sh
Important: Before running this script, please create at least one local website in DevKinsta!
Setup script to start automatic DB backups. You only need to run this script once (or after updating DevKinsta).
- Install the
cron
daemon in devkinsta_fpm container - Register the
cron
service to the containers autostart scripts - Extract the MySQL credentials from the an existing DevKinsta website
- Create a backup script that uses
mysqldump
to export each database to yourprivate/backups
folder - Register a cron task that calls the backup script every 3 hours.
bash setup-xdebug.sh --help
bash setup-xdebug.sh
Setup script to install and configure Xdebug for all available PHP modules. You only need to run this script once (or after updating DevKinsta).
- Installs the xdebug module for all available php services
- Creates xdebug.ini configuration
- Enables Xdebug
- Restarts all php services
bash wp-cron.sh --help
bash wp-cron.sh <website-dir> <interval>
# Examples:
bash wp-cron.sh example-site 10 # Configure wp-cron with a 10 minute interval
bash wp-cron.sh example-site 0 # Disable wp-cron for example-site
bash wp-cron.sh example-site now # Run wp-cron once without chaning the interval
<website-dir>
.. the folder name of the website inside the~/DevKinsta/public
folder.<interval>
.. accepts the following values:0
.. disable wp-cron- An integer value .. interval in minutes (e.g.
5
) now
.. run wp-cron once without modifying an existing cron interval
Configures a cron service that calls wp-cron for the specified website in a custom interval.
Notes: The wp-cron event is triggerd via WP CLI. If this script is called before setup-backups.sh
it will first install and configure the cron
daemon for you.
bash xdebug.sh --help
bash xdebug.sh <state>
# Examples:
bash xdebug.sh on # Enables Xdebug in all php services
bash xdebug.sh off # Completely disables Xdebug again
<state>
.. Either "on" or "off"
Enables or disables the xdebug php module. This script can only be used after calling setup-xdebug.sh
!
Tip: Only enable Xdebug when you actually need it. While the module is active, your local website-performance decreases considerably!
bash site.sh --help
bash site.sh <action> <website-dir>
# Examples:
bash site.sh disable example-site
bash site.sh enable example-site
<state>
.. Either "enable" or "disable"<website-dir>
.. the folder name of the website inside the~/DevKinsta/public
folder.
I noticed that DevKinsta gets slightly slower the more files are present inside the public
folder. This script will help to keep the public
folder lean and mean: When you "disable" a website, this script will move all files from the "public" folder to a new "archive" folder. At the same time, a small placeholder file is created inside your public-folder to remind you what happened to the website.
You can restore an archived website by calling the script with the action "enable" to undo that change.
bash server.sh --help
bash server.sh <web-server> <db-server>
# Examples:
bash server.sh kinsta mamp # Use Nginx of DevKinsta but link it to the MAMP Pro MySQL server
bash server.sh mamp mamp # MAMP Pro for webserver and MySQL
bash server.sh # Use DevKinsta for web server and MySQL
<web-server>
.. Either "kinsta" or "mamp". Default is "kinsta".<db-server>
.. Either "kinsta" or "mamp". Default is "kinsta".
This is a very specific script and will only work on a macOS machine that has MAMP Pro v6 installed. It also requires a certain MAMP Pro configuration, which is documented inside the shell script.
When you set up MAMP Pro correctly, this script can be used to quickly switch between webservers and DB servers. Both, MAMP and DevKinsta, use the same codebase (i.e. the DevKinsta/public/my-website
folder) but process that codebase using a differnt server.
Some use cases:
- For performance comparison of DevKinsta vs MAMP and to confirm migration of websites.
- MAMP uses Apache and DevKinsta nginx, this way you can have both
- Toggle between two DB states
- Quickly test a website on a mobile device using MAMP Viewer
What it does:
Web server: kinsta
- Quit the MAMP Pro app (which stops all MAMP servers)
- Restarts the two docker containers
devkista_fpm
anddevkinsta_nginx
- Restarts all php services in the
devkinsta_fpm
container
Web server: mamp
- Stops the two docker containers
devkista_fpm
anddevkinsta_nginx
- Starts the MAMP Pro app (which starts relevant MAMP servers)
DB Server: kinsta
- Updates all
wp-config.php
files and setsDB_HOST
to eitherdevkinsta_db
(when webserver is alsokinsta
)127.0.0.1:15100
(when webserver ismamp
)
DB Server: mamp
- Starts the MAMP Pro app (which starts relevant MAMP servers)
- Updates all
wp-config.php
files and setsDB_HOST
to eitherlocalhost:8889
(when webserver is alsomamp
)host.docker.internal:8889
(when webserver iskinsta
)
Some tips and notes on integrating those scripts with PhpStorm
When using PhpStorm, check out this guide on how to set up Xdebug for your project:
https://community.devkinsta.com/t/guide-how-to-set-up-xdebug-on-devkinsta-with-phpstorm/944/
In PhpStorm you can add the shell scripts above to your toolbar to quickly run commands like "Enable Xdebug" or "Run wp-cron":
- Open Settings | Tools | External Tools, add a new tool:
- Program:
bash
- Arguments:
{script and params}
, e.g.xdebug.sh on
- Working dir:
/Users/{name}/DevKinsta/private
- Activate "Open console for tool output" (not required but recommended)
- Program:
- Open Settings | Appearance & Behavior | Menus and Toolbars and add your custom tools to a menu
- I prefer the "Navigation Bar Toolbar" toolbar for this
- Here you can assign a custom icon to the tools; I've included some icons in the
private/asset
folder