Created
June 13, 2021 20:25
-
-
Save assoft/628b701b84161dfb88c44c203c97d030 to your computer and use it in GitHub Desktop.
Valet DB Create Extension
This file contains hidden or 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 | |
| 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