Summon Skeletor's minion: a Composer companion to unleash extra functionality with every
create-project
command.
composer install --dev aniftyco/skeletor
Make sure the following is set in the scripts
section of composer.json
:
"post-create-project-cmd": [
"NiftyCo\\Skeletor\\Runner::execute"
],
Then just create a Skeletorfile.php
in the root with this:
<?php
use NiftyCo\Skeletor\Skeletor;
return function (Skeletor $skeletor) {
// ...
};
$skeletor->text('Enter your name:', 'John Doe');
$skeletor->textarea('Enter a description:');
$skeletor->password('Enter your password:');
$skeletor->confirm('Do you agree?', true);
$skeletor->select('Choose an option:', ['Option 1', 'Option 2', 'Option 3']);
$skeletor->multiselect('Choose multiple options:', ['Option 1', 'Option 2', 'Option 3']);
$skeletor->suggest('Start typing:', ['Suggestion 1', 'Suggestion 2', 'Suggestion 3']);
$skeletor->search('Search for an option:', function ($query) {
return ['Result 1', 'Result 2', 'Result 3'];
});
$skeletor->multisearch('Search for multiple options:', function ($query) {
return ['Result 1', 'Result 2', 'Result 3'];
});
$skeletor->spin('Processing...', function () {
// long running task
return true;
});
$skeletor->progress('Processing items...', 100, function ($progress) {
for ($i = 0; $i < 100; $i++) {
$progress->advance();
}
});
$skeletor->info('This is an info message.');
$skeletor->alert('This is an alert message.');
$skeletor->warning('This is a warning message.');
$skeletor->error('This is an error message.');
$skeletor->intro('Welcome to the setup wizard.');
$skeletor->outro('Setup complete.');
$skeletor->readFile('path/to/file.txt');
$skeletor->writeFile('path/to/file.txt', 'New content');
$skeletor->removeFile('path/to/file.txt');
$skeletor->removeDirectory('path/to/directory');
$skeletor->exists('path/to/file.txt');
$skeletor->updateComposerJson(['require' => ['new/package' => '^1.0']]);
$skeletor->exec(['ls', '-la']);
$skeletor->table(['Header 1', 'Header 2'], [['Row 1 Col 1', 'Row 1 Col 2'], ['Row 2 Col 1', 'Row 2 Col 2']]);
$skeletor->pause(5);
$skeletor->replaceInFile( 'search string', 'replace string', 'path/to/file.txt')
$skeletor->pregReplaceInFile('/pattern/', 'replace string', 'path/to/file.txt');