— No reviews yet
0 installs
0 views
— view→install
Install
$ agentstack add skill-alizharb-agent-skills-create-php-attribute ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Are you the author of Create Php Attribute? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claimAbout
Create PHP Attribute
When To Use
Use this skill when stable metadata should be declared with PHP 8 attributes and consumed by application code, tests, middleware, scanners, or tooling.
Inputs Needed
- Attribute purpose, target, allowed arguments, consuming code, security impact, tests, and naming.
Workflow
- Confirm a custom attribute is better than a method, interface, config value, enum, policy, middleware, injection attribute, Eloquent attribute, queue attribute, Form Request attribute, resource attribute, or other Laravel built-in attribute.
- Inspect existing attribute and support-class conventions.
- Create the attribute under
app/Attributesunless the project already has a different convention. - Use native PHP
#[Attribute(...)]targets and repeatability flags. - Make the attribute class
final readonlywhen possible. - Type every constructor parameter.
- Keep the attribute as metadata only.
- Create or update the consumer that reads the attribute via reflection, routing, middleware, tests, or support tooling.
- Add tests for the consumer behavior.
- Run Pint and focused tests.
Files That May Be Created
app/Attributes/*.php- Consumer classes in middleware, support, testing, or scanner namespaces.
- Tests for the attribute consumer.
Files That May Be Modified
- Classes or methods that receive the attribute.
- Middleware, Actions, Services, Providers, tests, or architecture tests that consume the attribute.
Architecture Rules
- Attributes describe metadata; they do not perform business workflows.
- Do not use custom attributes to bypass Actions, Policies, DTOs, Events, Jobs, or Services.
- Prefer Laravel built-in attributes before custom attributes.
- Every custom attribute must have a real consumer when introduced.
- Custom attributes are metadata and must not be used to bypass dependency injection.
Testing Requirements
- Test the consumer behavior.
- Test invalid or missing metadata where relevant.
- Add architecture tests when the attribute marks security, sensitivity, external integrations, or layer boundaries.
Security Requirements
- Attributes must not store secrets.
- Attributes must not become the only authorization mechanism unless the consumer explicitly enforces policy or gate checks.
- Treat reflected metadata as code-level metadata, not trusted user input.
Review Checklist
- Is an attribute the simplest clear tool?
- Is there a consumer?
- Are targets and repeatability correct?
- Is the class immutable and typed?
- Are tests focused on behavior?
Examples
Good Example
// app/Attributes/RequiresPlan.php
namespace App\Attributes;
use Attribute;
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
final readonly class RequiresPlan
{
public function __construct(public string $plan = 'basic') {}
}
// app/Http/Middleware/CheckPlanSubscription.php
namespace App\Http\Middleware;
use Closure;
use ReflectionClass;
use App\Attributes\RequiresPlan;
use Illuminate\Http\Request;
final class CheckPlanSubscription
{
public function handle(Request $request, Closure $next)
{
$controller = $request->route()?->controller;
if (! $controller) {
return $next($request);
}
// Use reflection to check for attribute on controller class
$reflection = new ReflectionClass($controller);
$attribute = $reflection->getAttributes(RequiresPlan::class)[0] ?? null;
if ($attribute) {
$requiresPlan = $attribute->newInstance();
if (! $request->user()?->subscribed($requiresPlan->plan)) {
abort(403, 'Subscription Plan Required');
}
}
return $next($request);
}
}
Bad Example
// ❌ Constructing custom reflection tags, dynamic execution inside constructor, no targeting filters.
#[Attribute]
class RequiresPlan {
public function __construct($plan) {
if (!auth()->user()->subscribed($plan)) {
redirect('/billing'); // DO NOT run side-effects inside attributes!
}
}
}
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: AlizHarb
- Source: AlizHarb/agent-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.