Php attributes

From jpcaparas/superpowers-laravel · View interactive version

Php attributes is an AI agent skill from the GitHub repository jpcaparas/superpowers-laravel. Use first-party PHP attributes (Laravel 13+) for controllers, authorization, queue jobs, and models; declarative configuration colocated with code

How to use this skill

Skill file

First-Party PHP Attributes (Laravel 13+)

Laravel 13 expands attribute support across the framework. Prefer attributes when they colocate configuration with the class it affects and reduce boilerplate.

Commands

# Controller middleware + authorization
use Illuminate\Routing\Attributes\Controllers\Authorize;
use Illuminate\Routing\Attributes\Controllers\Middleware;

#[Middleware('auth')]
class CommentController
{
    #[Middleware('subscribed')]
    #[Authorize('create', [Comment::class, 'post'])]
    public function store(Post $post) { /* ... */ }
}

# Queue job controls
use Illuminate\Queue\Attributes\{Tries, Backoff, Timeout, FailOnTimeout};

#[Tries(3)]
#[Backoff([10, 30, 60])]
#[Timeout(120)]
#[FailOnTimeout]
class ProcessPodcast implements ShouldQueue { /* ... */ }

# Eloquent model attributes
use Illuminate\Database\Eloquent\Attributes\{DateFormat, WithoutTimestamps};

#[DateFormat('Y-m-d')]
#[WithoutTimestamps]
class Post extends Model { /* ... */ }

Patterns

Testing

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.