Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Silly Laravel Package

mnapoli/silly

Silly is a lightweight CLI micro-framework built on Symfony Console. Define commands with simple signatures and PHP callables, get options/arguments parsing, helpers, and DI integration (PHP-DI or Pimple) while staying compatible with Symfony Console apps.

View on GitHub
Deep Wiki
Context7

currentMenu: callable

Command callables

A command can be any PHP callable:

// Closure
$app->command('foo', function () {
    // ...
});

// An object implementing __invoke()
$app->command('foo', new InvokableObject());

// An object method
$app->command('foo', [$object, 'method']);

// A static class method
$app->command('foo', ['MyClass', 'method']);

// A function
$app->command('foo', 'someFunction');

Parameters

The callable can take as parameters the arguments and options defined in the expression:

$app->command('greet name [--yell]', function ($name, $yell) {
    // ...
});

The order of parameters doesn't matter as they are always matched by name.

When running $ bin/console greet john --yell:

  • $name will be 'john'
  • $yell will be true

Input and output

You can also ask for the $input and $output parameters to get the traditional Symfony InputInterface and OutputInterface objects (the type-hint is optional):

$app->command(
    'greet name [--yell]',
    function (InputInterface $input, OutputInterface $output) {
        $name = $input->getArgument('name');
        $yell = $input->getOption('yell');

        // ...
    }
);

You can also inject the SymfonyStyle object by type-hinting it:

use \Symfony\Component\Console\Style\SymfonyStyle;

...

$app->command('greet', function (SymfonyStyle $io) {
    $io->write('hello');
});

Finally, you can mix all that (remember the order of parameters doesn't matter):

$app->command(
    'greet name [--yell]',
    function ($name, InputInterface $input, OutputInterface $output) {
        // ...
    }
);

Dependency injection

It is also possible to set up dependency injection through the callables parameters. To learn more about that, read the Dependency injection documentation.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope