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: pimple

Pimple

As explained in the dependency injection documentation, Silly can work with any PSR-11 dependency injection container.

Pimple provides less features than the PHP-DI edition (for example no autowiring) but might interest those already familiar with it, e.g. Silex users.

Installation

$ composer require pimple/pimple ^3.0

Usage

Use Pimple as an application container:

$container    = new \Pimple\Container();
$psrContainer = new \Pimple\Psr11\Container($container);

$app = new \Silly\Application();
$app->useContainer($psrContainer);

You can store command callables in the container:

class MyCommand
{
    public function execute($name, OutputInterface $output)
    {
        if ($name) {
            $text = 'Hello, '.$name;
        } else {
            $text = 'Hello';
        }

        $output->writeln($text);
    }
}

$pimple = $app->getContainer();

$pimple['command.greet'] = function () {
    return new MyCommand();
};

$app->command('greet [name]', 'command.greet');

$app->run();

Dependency injection in parameters

You can also use dependency injection in parameters:

use Psr\Logger\LoggerInterface;

// ...

$pimple = $app->getContainer();

$pimple['dbHost'] = 'localhost';
$pimple[LoggerInterface::class] = function () {
    new Monolog\Logger(/* ... */);
};

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

$app->run();

Dependency injection in parameters follows the precedence rules explained in the dependency injection documentation:

  • command parameters are matched in priority using the parameter names ($name)
  • then container entries are matched using the callable type-hint (Psr\Logger\LoggerInterface)
  • finally container entries are matched using the parameter names ($dbHost)
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.
cadot.eu/make
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky