Created
December 14, 2019 14:46
-
-
Save schlessera/189179a4f9f7f08561a3d293f607f43a to your computer and use it in GitHub Desktop.
Simple script to quickly create a fresh WordPress installation in a subfolder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare( strict_types=1 ); | |
final class RoboFile extends \Robo\Tasks { | |
public function createEmpty( string $name, string $tld = 'localhost', string $email = '[email protected]' ) { | |
$io = $this->io(); | |
$root = __DIR__; | |
$io->title( 'Creating an empty local WordPress site' ); | |
$this->collectionBuilder() | |
->addTask( | |
$this->taskExec( "mkdir {$root}/{$name}" ) | |
) | |
->rollback( | |
$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}" ), | |
] ) | |
->completion( | |
$this->taskOpenBrowser( "https://{$name}.{$tld}" ) | |
) | |
->run(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment