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

Product Decisions This Supports

  • Internal Developer Tools (DevTools) Acceleration:

    • Build lightweight, reusable CLI tools for internal teams (e.g., database migrations, API testing, or deployment scripts) without reinventing the wheel.
    • Reduce dependency on monolithic frameworks like Laravel Artisan for simple CLI needs, lowering cognitive load and startup time.
  • Roadmap: CLI-First Features:

    • Enable "command-driven" workflows (e.g., php app.php migrate:fresh --seed) for Laravel-based products, aligning with Laravel’s ecosystem while keeping flexibility.
    • Build vs. Buy: Avoid building a custom CLI layer when Silly provides 80% of the functionality with minimal overhead. Justify adoption by comparing it to Symfony Console directly (no abstraction tax).
  • Use Cases:

    • Developer Experience (DX): Ship CLI tools for end-users (e.g., php app.php setup --interactive) to reduce onboarding friction.
    • Automation: Replace Bash/Python scripts with PHP-based CLI tools for consistency in polyglot environments (e.g., Laravel + Node.js).
    • Extensibility: Allow third-party developers to contribute commands to your product via a standardized interface (e.g., plugins for a SaaS product).
  • Dependency Injection (DI) Strategy:

    • Standardize on PSR-11 containers (PHP-DI or Pimple) for CLI commands, enabling:
      • Reusable services across CLI and web layers (e.g., shared LoggerInterface).
      • Testability by mocking dependencies in commands.
    • Example: Use PHP-DI for new projects to leverage autowiring; Pimple for legacy Silex-based codebases.
  • Performance-Critical CLI Tools:

    • Silly’s minimal footprint (~10KB) makes it ideal for high-frequency CLI tasks (e.g., real-time data processing scripts) where Symfony Console’s overhead is prohibitive.

When to Consider This Package

  • Look Elsewhere If:

    • You need GUI integration: Silly is CLI-only; pair with Symfony UI or Laravel Nova for dashboards.
    • Your commands require complex state management: Use Symfony Full Stack or Laravel for session/route-based workflows.
    • You’re building a public-facing API: Silly is for CLI, not HTTP endpoints (use Laravel API resources instead).
    • Your team lacks PHP CLI experience: Silly assumes familiarity with Symfony Console’s patterns (e.g., InputInterface).
    • You need advanced async support: Silly is synchronous; use ReactPHP or Symfony Messenger for async tasks.
  • Adopt Silly When:

    • Your CLI tools are >70% boilerplate (e.g., argument parsing, help generation).
    • You’re already using Symfony Console elsewhere in the codebase (avoid duplication).
    • Your commands share dependencies with web services (leverage DI containers).
    • You want zero-configuration for simple commands (e.g., php app.php greet --name=Alice).
    • Your team prefers PHP over Bash/Python for maintainability (e.g., type safety, IDE support).

How to Pitch It (Stakeholders)

For Executives:

*"Silly lets us ship CLI tools faster and with fewer bugs. For example, we can replace our custom Bash scripts for database migrations with a PHP-based command like php app.php migrate:reset --force, which is:

  • 10x more maintainable (type hints, autocompletion, tests).
  • Reusable across our Laravel and non-Laravel services.
  • Future-proof—it integrates with our existing Symfony-based tools.

This reduces dev time by 30% for internal tools and enables us to offer CLI-driven features to customers (e.g., php app.php setup) without hiring specialized CLI engineers. The MIT license and Tidelift support also mitigate risk."*

For Engineering:

*"Silly is a thin wrapper around Symfony Console that adds:

  1. Dependency Injection: Use PHP-DI or Pimple to inject services into commands (e.g., LoggerInterface $logger).
  2. Flexible Callables: Define commands as closures, classes, or static methods—no forced architecture.
  3. Laravel Compatibility: Works alongside Artisan; can even extend Laravel’s CLI ecosystem.

Example: Replace this Bash script:

#!/bin/bash
NAME=$1
if [ -z "$NAME" ]; then echo "Hello"; else echo "Hello, $NAME"; fi

With this PHP command (10 lines, type-safe):

$app->command('greet [name]', function (string $name = 'World') {
    echo "Hello, {$name}!";
});

Why not Symfony Console directly?

  • Silly’s Application class handles edge cases (e.g., command defaults, hyphen-to-camelCase conversion) out of the box.
  • Built-in DI support saves us from writing custom resolvers.

Migration Path:

  • Start with simple closures for quick wins.
  • Gradually adopt PHP-DI for complex commands to share services with web layers.
  • Replace 1–2 Bash scripts/month with Silly to prove ROI."*

For Developers:

*"Silly gives you:

  • Symfony Console’s power (help menus, argument parsing) with less boilerplate.
  • DI out of the box: No more manually instantiating services in commands.
  • Laravel-friendly: Works in Laravel projects without conflicts.

Try This:

// Install
composer require mnapoli/silly

// Create a command
$app = new \Silly\Application();
$app->command('deploy [--dry-run]', function (bool $dryRun) {
    if ($dryRun) {
        echo "Would deploy...";
    } else {
        echo "Deploying!";
    }
});
$app->run();

Run with:

php deploy.php deploy --dry-run

Pro Tip: Use PHP-DI for autowiring:

$app = new \Silly\Application\PhpDi();
$app->command('log [message]', function (LoggerInterface $logger, string $message) {
    $logger->info($message);
});
```"*
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.
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment