laravel-template-method-and-plugins

Stabilize workflows with Template Method or Strategy; extend by adding new classes instead of editing core logic

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "laravel-template-method-and-plugins" with this command: npx skills add noartem/laravel-vue-skills/noartem-laravel-vue-skills-laravel-template-method-and-plugins

Template Method and Pluggable Strategies

Keep core flows stable; enable extension via small classes.

Template Method

Use a base class that defines the algorithm skeleton; subclasses override hooks.

abstract class Importer {
    final public function handle(string $path): void {
        $rows = $this->load($path);
        $data = $this->normalize($rows);
        $this->validate($data);
        $this->save($data);
    }
    abstract protected function load(string $path): array;
    protected function normalize(array $rows): array { return $rows; }
    protected function validate(array $data): void {}
    abstract protected function save(array $data): void;
}

Strategy/Plugin

Define an interface; register implementations; select by key/config.

interface PaymentGateway { public function charge(int $cents, string $currency): string; }

final class StripeGateway implements PaymentGateway { /* ... */ }
final class BraintreeGateway implements PaymentGateway { /* ... */ }

final class PaymentsRegistry {
    /** @param array<string,PaymentGateway> $drivers */
    public function __construct(private array $drivers) {}
    public function for(string $key): PaymentGateway { return $this->drivers[$key]; }
}

Prefer adding a class over editing switch statements. Test implementations in isolation.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

shadcn-vue

No summary provided by upstream source.

Repository SourceNeeds Review
General

laravel-routes-best-practices

No summary provided by upstream source.

Repository SourceNeeds Review
General

baseline-ui

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

laravel-iterating-on-code

No summary provided by upstream source.

Repository SourceNeeds Review