Automated summary
Adds a new event hook to src/Plugin.php by registering it in getHooks() and creating the corresponding static GenericEvent handler.
Strengths
- States the exact signature constraints (public static, single GenericEvent parameter) enforced by existing tests
- Mandates the category guard and stopPropagation as the final statement in the handler body
- Documents the self::$module.'.event_name' key convention plus the 'function.requirements' literal-key exception
- Includes updating tests/PluginTest.php (expected keys and method count) and verifying with composer test
Limitations
- Highly specific to one PHP plugin using GenericEvent, get_service_define and myadmin_log
- Explicitly excludes modifying existing handlers and adding inc functions
- Assumes the GenericEvent import already exists and gives no broader architectural context
Use it when you need to wire a new lifecycle event (activate, deactivate, change IP, reactivate) into the plugin.
Do not use it to modify an existing handler or to add a function to the inc files.
Security analysis
SafeThe skill provides concrete, narrow instructions for editing a PHP plugin file and its tests. It does not instruct destructive commands, network exfiltration, secret handling, obfuscated payloads, or disabling safety mechanisms.
No concerns found
How this analysis is madeExamples
Add a hook for licenses.change_ip that logs the old and new IP address.Add a hook for the reactivate lifecycle event and point it at the existing getActivate handler instead of creating a new method.Add a new change_ip hook whose handler calls an inc function, register the requirement in getRequirements(), and update the tests.name: plugin-hook description: Adds a new event hook to src/Plugin.php — registers in getHooks() and creates the static GenericEvent handler. Use when user says 'add hook', 'handle event', 'new plugin event', or adds a lifecycle action (activate/deactivate/change IP/reactivate). Do NOT use for modifying existing handlers or adding inc functions.
plugin-hook
Critical
- All handler methods MUST be
public staticand accept exactly oneGenericEvent $eventparameter —testHookMethodsArePublicAndStaticandtestEventHandlerMethodSignatureswill fail otherwise. - Always guard the handler body with
if ($event['category'] == get_service_define('PARALLELS'))before any logic. - Always call
$event->stopPropagation()as the last statement inside the category guard. - Hook keys use
self::$module . '.event_name'(e.g.'licenses.change_ip') — never hardcode the module string. - The one exception is
'function.requirements'which uses a literal key, not the module prefix. - Run
composer testafter every change — a missing method or wrong signature will breaktestAllHookMethodsExistandtestClassMethodCount.
Instructions
-
Decide the event name and handler name. Event name is snake_case (e.g.
change_ip). Handler is PascalCase prefixed withget(e.g.getChangeIp). Verify no existing entry ingetHooks()already covers this event. -
Register the hook in
getHooks()insidesrc/Plugin.php. Add one line to the returned array:self::$module.'.change_ip' => [__CLASS__, 'getChangeIp'],If the new event should share an existing handler (like
reactivate→getActivate), point to the existing method name instead of creating a new one. Verify the array key is unique before proceeding. -
Add the handler method to
src/Plugin.phpafter the last existing handler, before the closing}:/** * @param \Symfony\Component\EventDispatcher\GenericEvent $event */ public static function getChangeIp(GenericEvent $event) { if ($event['category'] == get_service_define('PARALLELS')) { $serviceClass = $event->getSubject(); myadmin_log(self::$module, 'info', 'Parallels <Action Description>', __LINE__, __FILE__, self::$module, $serviceClass->getId()); // ... call function_requirements() then the inc function ... $event->stopPropagation(); } }The
use Symfony\Component\EventDispatcher\GenericEvent;import is already present at the top — do not add it again. -
If the handler calls an inc function, add
function_requirements('your_function')before the call and register the function path ingetRequirements():$loader->add_requirement('your_function', '/../src/parallels.inc.php');Verify the function exists in
src/parallels.inc.phpbefore registering. -
Update
tests/PluginTest.php— add the new hook key to the$expectedKeysarray intestGetHooksContainsExpectedKeys()and bump the count intestClassMethodCount()if a new method was added. Runcomposer testto confirm all tests pass.
Examples
User says: "Add a hook for licenses.change_ip that logs the old and new IP"
Actions taken:
getHooks() addition in src/Plugin.php:
self::$module.'.change_ip' => [__CLASS__, 'getChangeIp'],
New handler method in src/Plugin.php:
public static function getChangeIp(GenericEvent $event)
{
if ($event['category'] == get_service_define('PARALLELS')) {
$serviceClass = $event->getSubject();
myadmin_log(self::$module, 'info', 'IP Change - (OLD:'.$serviceClass->getIp().") (NEW:{$event['newip']})", __LINE__, __FILE__, self::$module, $serviceClass->getId());
// perform IP change logic here
$event['status'] = 'ok';
$event['status_text'] = 'The IP Address has been changed.';
$event->stopPropagation();
}
}
Result: composer test passes; testGetHooksContainsExpectedKeys and testAllHookMethodsExist both green.
Common Issues
testClassMethodCountfails with "Expected 7, got 8": You added a new handler but did not update the count assertion intests/PluginTest.php. Change theassertCount(7, ...)to the new total.testAllHookMethodsExistfails: The method name string ingetHooks()does not exactly match the declared method name. Check spelling and PascalCase —getChangeIp≠getChangeIP.testEventHandlerMethodSignaturesfails with "parameter should be GenericEvent": The handler is missing theGenericEvent $eventtype hint, or theusestatement is absent (it lives at the top ofsrc/Plugin.php— do not remove it).stopPropagationnot called: Event will continue dispatching to other plugins and produce duplicate side-effects. Always place$event->stopPropagation()as the final statement inside the category guard.function_requirementsnot registered: Ifactivate_parallelsor a new inc function is called but not registered ingetRequirements(), it will throw a fatal error at runtime. Verify$loader->add_requirement('fn_name', '...')is present.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/add-event-hook-to-plugin-php-mrwakdo8/download' --output '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md.part' && mv '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md.part' '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md' && test -s '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/plugin-hook' && cp -R '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8' '.claude/skills/plugin-hook'Cursor
test -f '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md' && test -s '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/plugin-hook' && cp -R '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8' '.cursor/skills/plugin-hook'Codex
test -f '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md' && test -s '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/plugin-hook' && cp -R '.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8' '.agents/skills/plugin-hook'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/add-event-hook-to-plugin-php-mrwakdo8'openskills read 'add-event-hook-to-plugin-php-mrwakdo8'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/add-event-hook-to-plugin-php-mrwakdo8/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.