Php Patterns logo

Php Patterns

Organization
OrcaQubits
php-patterns

Apply PHP design patterns — Repository, Factory, Strategy, Decorator, Observer, Singleton, Builder, and Dependency Injection patterns in PHP. Use when architecting PHP applications or understanding patterns used in Magento and other frameworks.

Overview

PublisherOrcaQubits
Repositoryagentic-commerce-skills-plugins
Skill namephp-patterns
Stars
40
Forks
17
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by OrcaQubits on GitHub. Read the source before you install it.

Installation

Install the Php Patterns AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/OrcaQubits/agentic-commerce-skills-plugins/tree/main/magento2-commerce/skills/php-patterns
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/OrcaQubits/agentic-commerce-skills-plugins.git /tmp/agentic-commerce-skills-plugins
mkdir -p .claude/skills
cp -r /tmp/agentic-commerce-skills-plugins/magento2-commerce/skills/php-patterns .claude/skills/php-patterns
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Php Patterns in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Php Patterns on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Php Patterns is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

PHP Design Patterns

Before writing code

Fetch live docs: Web-search php design patterns examples for current community patterns and best practices. For Magento-specific patterns, web-search site:developer.adobe.com commerce php development components.

Creational Patterns

Factory

Creates objects without exposing instantiation logic. In Magento, auto-generated Factory classes (SomeModelFactory) create non-injectable objects via $factory->create().

When to use: When you need new instances (entities, models) rather than shared singletons. When the caller shouldn't know the concrete class.

Builder

Constructs complex objects step by step. Magento's SearchCriteriaBuilder, FilterBuilder, SortOrderBuilder follow this pattern.

When to use: When object construction requires many optional parameters or multi-step assembly.

Singleton (Shared Instance)

Single instance shared across the application. Magento's Object Manager shares instances by default. Explicit singleton is generally an anti-pattern — prefer DI container sharing.

When to use: Rarely — let the DI container manage instance sharing.

Structural Patterns

Proxy

Delays instantiation of resource-intensive dependencies. Magento auto-generates Proxy classes (SomeClass\Proxy) that create the real object only when a method is called.

When to use: When a class injects a heavy dependency it doesn't always use.

Decorator

Wraps an object to add behavior without modifying the original. Used in Magento composite components and cache decorators.

When to use: When you need to add behavior to an object dynamically without subclassing.

Composite

Treats individual objects and compositions uniformly. Magento's UI component tree and layout container system follow this pattern.

When to use: When you have tree-structured data or components.

Behavioral Patterns

Strategy

Defines a family of algorithms, encapsulates each one, makes them interchangeable. Magento shipping carriers and payment methods are strategy implementations.

When to use: When you have multiple algorithms for the same task and want runtime selection.

Observer

Defines a one-to-many dependency. When one object changes state, all dependents are notified. Magento's event/observer system is a direct implementation.

When to use: When changes in one object should trigger actions in others without tight coupling.

Repository

Mediates between domain and data mapping layers. Magento's repository interfaces (ProductRepositoryInterface) centralize all data access through a clean API.

When to use: Always — for any data access beyond simple reads. It's the standard Magento pattern.

Command

Encapsulates a request as an object. Magento's Payment Gateway Command pattern uses this — authorize, capture, refund are separate command objects.

When to use: When you need to parameterize, queue, or log requests.

Architectural Patterns

Dependency Injection

Objects receive their dependencies through constructors rather than creating them. Magento's DI container (Object Manager + di.xml) is the foundation of the entire framework.

When to use: Always — it's the core pattern. Inject interfaces, not concrete classes.

Service Layer

Defines an application's boundary with a layer of services that encapsulates business logic. Magento's Service Contracts (interfaces in Api/) form this layer.

When to use: Always — expose module functionality through service interfaces.

Data Transfer Object (DTO)

Simple objects that carry data between processes. Magento's Data Interfaces (Api/Data/) are DTOs — they have getters/setters but no business logic.

When to use: When passing data across architectural boundaries (API, service layer).

Anti-Patterns to Avoid

  • God Object — classes that do too much (split into focused services)
  • Service Locator — calling Object Manager directly (use constructor injection)
  • Anemic Domain Model — models with only getters/setters (add behavior where appropriate)
  • Tight Coupling — depending on concrete classes (depend on interfaces)
  • Hard-coded Dependencies — instantiating with new (use factories or DI)

Best Practices

  • Program to interfaces, not implementations
  • Favor composition over inheritance
  • Keep classes focused (Single Responsibility)
  • Use DI container for dependency management
  • Use factories for creating non-shared instances
  • Use proxies for lazy-loading expensive dependencies
  • Use the strategy pattern for swappable algorithms
  • Document which pattern a class implements

Fetch current framework documentation for exact interface signatures and implementation patterns before applying.

Frequently asked questions

What does the Php Patterns AI skill do?

Apply PHP design patterns — Repository, Factory, Strategy, Decorator, Observer, Singleton, Builder, and Dependency Injection patterns in PHP. Use when architecting PHP applications or understanding patterns used in Magento and other frameworks.

Why use Php Patterns on TypingMind?

Because you install it once and use it with any model. Php Patterns is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Php Patterns in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/OrcaQubits/agentic-commerce-skills-plugins/tree/main/magento2-commerce/skills/php-patterns. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Php Patterns?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Php Patterns?

As many as you like. As long as a model supports skills, you can use Php Patterns with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Php Patterns AI skill free?

Yes. It is published on GitHub by OrcaQubits under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇