承接 i74ifa/role-craft 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

i74ifa/role-craft

Composer 安装命令:

composer require i74ifa/role-craft

包简介

automating role creation and permission management with Spatie/Laravel-Permission.

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

Installation

composer require i74ifa/role-craft

Version Compatibility

Version Laravel Spatie Permission PHP
v2.x 12.0+ / 13.0+ 7.0+ 8.4+
v1.x 10.0+ / 11.0+ 6.x 8.2+

optional

publish config

php artisan vendor:publish --tag=role-craft-config

AI agent guide

This package ships an agent-neutral usage guide for AI coding assistants at:

vendor/i74ifa/role-craft/docs/AGENT_GUIDE.md

It covers every config key, command flag, per-model override, naming rule, and common recipe in one place. It is plain Markdown — readable by humans and by any agent (Cursor, Cline, Aider, GitHub Copilot, Codex, Claude Code, etc.).

To make your agent pick it up automatically, reference the path from whichever rules file your tool uses, for example:

  • AGENTS.md (Codex / generic) — link or include the file.
  • .cursor/rules/*.mdc (Cursor) — @vendor/i74ifa/role-craft/docs/AGENT_GUIDE.md.
  • .github/copilot-instructions.md (GitHub Copilot) — link to the file.
  • CLAUDE.md or .claude/skills/role-craft/SKILL.md (Claude Code) — link to or copy the file.
  • .clinerules, .windsurfrules, .continuerules — reference the file path.

Usage

Generate role and Permissions

php artisan role-craft:generate

this command will be generate all permissions and role-craft.default_role will be created if you want to change default role name, you can change it in config/role-craft.php after publish config

Sync permissions

php artisan role-craft:sync manager --all

this will be sync all permissions to manager role if it exists if not exists you want to use --create option

php artisan role-craft:sync manager --create

if you want to sync some role from models use --models option

php artisan role-craft:sync manager --models=User --models=Post

# OR Custom Directory
php artisan role-craft:sync manager --models=App\Models\Directory\User

Generate role if not exists

php artisan role-craft:sync manager --create

Including models (whitelist)

Some projects don't need permissions for every model in app/Models. To restrict scanning to a curated set, fill included_models in config/role-craft.php. When the list is non-empty, role-craft only processes models matching one of the patterns — everything else is treated as "excluded all":

// config/role-craft.php

'included_models' => [
    App\Models\User::class,          // exact class
    'App\Models\Billing\*',          // whole subtree
    '*\Public\*',                    // any "Public" folder anywhere
],

When included_models is empty (the default), every Eloquent model under models_path is included.

Excluding models (blacklist)

If you want to skip one or more models, add them to the excluded_models array. Excludes are applied after the include filter, so you can whitelist a subtree and then carve a few classes out of it:

// config/role-craft.php

'excluded_models' => [
    App\Models\User::class,          // exact class
    'App\Models\Internal\*',         // every model under app/Models/Internal
    '*\Pivot\*',                     // any "Pivot" folder anywhere
],

Notes:

  • Both filters use fnmatch on the fully-qualified class name (leading backslashes are normalized).
  • The filters are only applied during directory scans. Passing --models=Foo explicitly still includes Foo — user intent wins.
  • Order of operations: included_models first (if non-empty), then excluded_models.

Per-model customization

Override the permission name or action list on a specific model by declaring public properties on it:

class Post extends Model
{
    // Replaces the table-name segment in the permission name
    public $prefix_permissions = 'blog_posts';

    // Replaces the default action list for this model
    public $prefix_model_permissions = ['create', 'view', 'publish', 'archive'];
}

License

This package is released under the MIT license.

i74ifa/role-craft 适用场景与选型建议

i74ifa/role-craft 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34 次下载、GitHub Stars 达 4, 最近一次更新时间为 2025 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「permission」 「role」 「spatie」 「laravel-permission」 「i74ifa」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 i74ifa/role-craft 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 i74ifa/role-craft 我们能提供哪些服务?
定制开发 / 二次开发

基于 i74ifa/role-craft 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 34
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-28