Skip to content

Instantly share code, notes, and snippets.

@assoft
Created June 13, 2021 20:25
Show Gist options
  • Select an option

  • Save assoft/628b701b84161dfb88c44c203c97d030 to your computer and use it in GitHub Desktop.

Select an option

Save assoft/628b701b84161dfb88c44c203c97d030 to your computer and use it in GitHub Desktop.
Valet DB Create Extension
<?php
namespace Valet;
use function Valet\info;
use function Valet\warning;
// Put this file in your ~/config/.valet/Extensions directory!
/**
* Create a new database on your local machine.
*/
$app->command('db:create [name]', function ($name) {
$command = new CommandLine();
if (!$name) {
warning('Please specify a database name');
return;
}
if ($error = $command->run('mysql -uroot -e "create database ' . $name . '"')) {
warning($error);
} else {
info('The database ' . $name . ' has been created');
}
})->descriptions('Create a new database');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment