Skip to content

Instantly share code, notes, and snippets.

Last active February 3, 2020 23:21
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Simple script to quickly create a fresh WordPress installation in a subfolder.

Site creation script

This simple Robo script let's you quickly pull up a new site via Valet+.

This was mention and demonstrated during Episode of my "Personal Home Page" livestream. More information about the livestream can be found at



robo create:empty <name> [<tld>] [<email>]

You can create a wrapper script for Robo, or install it as a local Composer dependency for convenience.

<?php declare( strict_types=1 );
final class RoboFile extends \Robo\Tasks {
public function createEmpty( string $name, string $tld = 'localhost', string $email = '' ) {
$io = $this->io();
$root = __DIR__;
$io->title( 'Creating an empty local WordPress site' );
$this->taskExec( "mkdir {$root}/{$name}" )
$this->taskDeleteDir( "{$root}/{$name}" )
->addTaskList( [
$this->taskExec( "cd {$root}/{$name}" ),
$this->taskExec( 'valet secure' )
->arg( $name ),
$this->taskExec( 'wp core download' )
->option( "path={$root}/{$name}" ),
$this->taskExec( 'wp core config' )
->option( "path={$root}/{$name}" )
->option( "dbname={$name}" )
->option( 'dbuser=root' )
->option( 'dbpass=root' ),
$this->taskExec( 'wp db create' )
->option( "path={$root}/{$name}" ),
$this->taskExec( 'wp core install' )
->option( "path={$root}/{$name}" )
->option( "url=https://{$name}.{$tld}" )
->option( "title={$name}" )
->option( 'admin_user=admin' )
->option( 'admin_password=password' )
->option( "admin_email={$email}" ),
] )
$this->taskOpenBrowser( "https://{$name}.{$tld}" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment