Token导航 LogoToken导航TokenDH.com
开发规范需要联网github未标认证来源可访问clear审计未展示

php-guidelines-from-spatiePHP guidelines from spatie 命令行

Agent Skill

php-guidelines-from-spatie 用于辅助前端页面、组件、样式和交互逻辑开发,适合在 Codex、Claude、Cursor、Gemini CLI 中需要维护前端项目、生成组件或检查界面实现时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

2,424

周安装

101

GitHub Stars

公开资料未说明

下载量

808
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:php-guidelines-from-spatie(PHP guidelines from spatie 命令行)
来源仓库:https://github.com/freekmurze/dotfiles
仓库路径:skills/php-guidelines-from-spatie
安装命令:
npx skills add freekmurze/dotfiles --skill "php-guidelines-from-spatie"
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

AgentSkills.tonpx skills
npx skills add freekmurze/dotfiles --skill "php-guidelines-from-spatie"

简介

php-guidelines-from-spatie 用于辅助前端页面、组件、样式和交互逻辑开发。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中需要维护前端项目、生成组件或检查界面实现时使用。
  • 通过 npx skills add freekmurze/dotfiles --skill "php-guidelines-from-spatie" 命令安装。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • 可结合来源仓库和原始 README 继续核验具体用法和功能边界。

SKILL.md

name
php-guidelines-from-spatie
description
Describes PHP and Laravel guidelines provided by Spatie. These rules result in more maintainable, and readable code.
license
MIT
metadata
author
Spatie
tags
php, laravel, best practices, coding standards

Core Laravel Principle

Follow Laravel conventions first. If Laravel has a documented way to do something, use it. Only deviate when you have a clear justification.

PHP Standards

  • Follow PSR-1, PSR-2, and PSR-12
  • Use camelCase for non-public-facing strings
  • Use short nullable notation: ?string not string|null
  • Always specify void return types when methods return nothing

Class Structure

  • Use typed properties, not docblocks:
  • Constructor property promotion when all properties can be promoted:
  • One trait per line:

Type Declarations & Docblocks

  • Use typed properties over docblocks
  • Specify return types including void
  • Use short nullable syntax: ?Type not Type|null
  • Document iterables with generics:
  /** @return Collection<int, User> */
  public function getUsers(): Collection

Docblock Rules

  • Don't use docblocks for fully type-hinted methods (unless description needed)
  • Always import classnames in docblocks - never use fully qualified names:
  use \Spatie\Url\Url;
  /** @return Url */
  • Use one-line docblocks when possible: /** @var string */
  • Most common type should be first in multi-type docblocks:
  /** @var Collection|SomeWeirdVendor\Collection */
  • If one parameter needs docblock, add docblocks for all parameters
  • For iterables, always specify key and value types:
  /**
   * @param array<int, MyObject> $myArray
   * @param int $typedArgument 
   */
  function someFunction(array $myArray, int $typedArgument) {}
  • Use array shape notation for fixed keys, put each key on it's own line:
  /** @return array{
     first: SomeClass, 
     second: SomeClass
  } */

Control Flow

  • Happy path last: Handle error conditions first, success case last
  • Avoid else: Use early returns instead of nested conditions
  • Separate conditions: Prefer multiple if statements over compound conditions
  • Always use curly brackets even for single statements
  • Ternary operators: Each part on own line unless very short
// Happy path last
if (! $user) {
    return null;
}

if (! $user->isActive()) {
    return null;
}

// Process active user...

// Short ternary
$name = $isFoo ? 'foo' : 'bar';

// Multi-line ternary
$result = $object instanceof Model ?
    $object->name :
    'A default value';

// Ternary instead of else
$condition
    ? $this->doSomething()
    : $this->doSomethingElse();

Laravel Conventions

Routes

  • URLs: kebab-case (/open-source)
  • Route names: camelCase (->name('openSource'))
  • Parameters: camelCase ({userId})
  • Use tuple notation: [Controller::class, 'method']

Controllers

  • Plural resource names (PostsController)
  • Stick to CRUD methods (index, create, store, show, edit, update, destroy)
  • Extract new controllers for non-CRUD actions

Configuration

  • Files: kebab-case (pdf-generator.php)
  • Keys: snake_case (chrome_path)
  • Add service configs to config/services.php, don't create new files
  • Use config() helper, avoid env() outside config files

Artisan Commands

  • Names: kebab-case (delete-old-records)
  • Always provide feedback ($this->comment('All ok!'))
  • Show progress for loops, summary at end
  • Put output BEFORE processing item (easier debugging):
  $items->each(function(Item $item) {
      $this->info("Processing item id `{$item->id}`...");
      $this->processItem($item);
  });
  
  $this->comment("Processed {$items->count()} items.");

Strings & Formatting

  • String interpolation over concatenation:

Enums

  • Use PascalCase for enum values:

Comments

Be very critical about adding comments as they often become outdated and can mislead over time. Code should be self-documenting through descriptive variable and function names.

Adding comments should never be the first tactic to make code readable.

*Instead of this:*

// Get the failed checks for this site
$checks = $site->checks()->where('status', 'failed')->get();

*Do this:*

$failedChecks = $site->checks()->where('status', 'failed')->get();

Guidelines:

  • Don't add comments that describe what the code does - make the code describe itself
  • Short, readable code doesn't need comments explaining it
  • Use descriptive variable names instead of generic names + comments
  • Only add comments when explaining *why* something non-obvious is done, not *what* is being done
  • Never add comments to tests - test names should be descriptive enough

Whitespace

  • Add blank lines between statements for readability
  • Exception: sequences of equivalent single-line operations
  • No extra empty lines between {} brackets
  • Let code "breathe" - avoid cramped formatting

Validation

  • Use array notation for multiple rules (easier for custom rule classes):
  public function rules() {
      return [
          'email' => ['required', 'email'],
      ];
  }
  • Custom validation rules use snake_case:
  Validator::extend('organisation_type', function ($attribute, $value) {
      return OrganisationType::isValid($value);
  });

Blade Templates

  • Indent with 4 spaces
  • No spaces after control structures:
  @if($condition)
      Something
  @endif

Authorization

  • Policies use camelCase: Gate::define('editPost', ...)
  • Use CRUD words, but view instead of show

Translations

  • Use __() function over @lang:

API Routing

  • Use plural resource names: /errors
  • Use kebab-case: /error-occurrences
  • Limit deep nesting for simplicity:
  /error-occurrences/1
  /errors/1/occurrences

Testing

  • Keep test classes in same file when possible
  • Use descriptive test method names
  • Follow the arrange-act-assert pattern

Quick Reference

Naming Conventions

  • Classes: PascalCase (UserController, OrderStatus)
  • Methods/Variables: camelCase (getUserName, $firstName)
  • Routes: kebab-case (/open-source, /user-profile)
  • Config files: kebab-case (pdf-generator.php)
  • Config keys: snake_case (chrome_path)
  • Artisan commands: kebab-case (php artisan delete-old-records)

File Structure

  • Controllers: plural resource name + Controller (PostsController)
  • Views: camelCase (openSource.blade.php)
  • Jobs: action-based (CreateUser, SendEmailNotification)
  • Events: tense-based (UserRegistering, UserRegistered)
  • Listeners: action + Listener suffix (SendInvitationMailListener)
  • Commands: action + Command suffix (PublishScheduledPostsCommand)
  • Mailables: purpose + Mail suffix (AccountActivatedMail)
  • Resources/Transformers: plural + Resource/Transformer (UsersResource)
  • Enums: descriptive name, no prefix (OrderStatus, BookingType)

Migrations

  • do not write down methods in migrations, only up methods

Code Quality Reminders

PHP

  • Use typed properties over docblocks
  • Prefer early returns over nested if/else
  • Use constructor property promotion when all properties can be promoted
  • Avoid else statements when possible
  • Use string interpolation over concatenation
  • Always use curly braces for control structures

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

28.37%
按下载量换算229

Antigravity

23.8%
按下载量换算192

OpenCode

17.77%
按下载量换算144

Codex

14%
按下载量换算113

Gemini CLI

8.82%
按下载量换算71

windsurf

3.42%
按下载量换算28

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills