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.
phpshko/laravel-livewire-depdrop
larasell-dev/larasell
calliostro/spotify-bundle
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer