定制 cnd-api-maker/laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

cnd-api-maker/laravel

最新稳定版本:v0.1.5

Composer 安装命令:

composer require cnd-api-maker/laravel

包简介

README 文档

README

Laravel integration for Cnd API Maker.

This package builds on top of cnd-api-maker/core and provides:

  • Laravel Service Provider (auto-discovered)
  • Artisan commands
  • Laravel generators (migrations, models, factories, seeders, tests… depending on enabled modules)
  • API Platform (Laravel) resource generation (if api-platform/laravel is installed)

Requirements

  • PHP 8.2+
  • Laravel 10 / 11 / 12
  • cnd-api-maker/core
  • (optional) api-platform/laravel if you generate API Platform resources

Install

Public install (Packagist)

composer require cnd-api-maker/laravel

Local dev install (monorepo path)

In your Laravel app composer.json:

{
  "repositories": [
    { "type": "path", "url": "../cnd-api-maker/packages/cnd-api-maker/core" },
    { "type": "path", "url": "../cnd-api-maker/packages/cnd-api-maker/laravel" }
  ],
  "require": {
    "cnd-api-maker/laravel": "*"
  },
  "minimum-stability": "dev",
  "prefer-stable": true
}

Then:

composer update cnd-api-maker/core cnd-api-maker/laravel

Laravel registration

Auto-discovery is enabled via:

"extra": {
  "laravel": {
    "providers": [
      "CndApiMaker\\Laravel\\ApiPlatformMakerServiceProvider"
    ]
  }
}

If auto-discovery is disabled, register the provider manually in config/app.php.

Configuration

Quick start

install

  • 1 create a laravel project

composer create-project laravel/laravel starter-laravel

  • 2 create a laravel project

composer require cnd-api-maker/laravel

1) Create a JDL file

Create a .jdl file describing your entities and relationships.

Example: example.jdl

entity Employee {
  firstName String required
  lastName String required
  email String
  phoneNumber String
  hireDate Instant
  salary Long
  commissionPct Long
}

entity Ticket {
  title String required
  due Long
}

relationship OneToMany {
  Employee to Ticket{employee}
}

Generate JDL using JHipster JDL Studio:

2) Install the generator (one-time)

php artisan cnd:api-maker:install --force

3) Generate from JDL

php artisan cnd:api-maker:generate --file=example.jdl

Common options (depending on your implementation):

  • --force overwrite generated files
  • --dry-run preview without writing
  • --module=... generate into a specific module/namespace (if supported)

4) Run database + tests

php artisan migrate
php artisan test

Generated output (example: multi-tenant + RBAC starter)

API / Config

  • app/ApiResource/Health.php
  • config/api-platform.php
  • bootstrap/app.php
  • bootstrap/providers.php

Console / Providers

  • app/Console/Commands/GeneratePermissionsCommand.php
  • app/Providers/TenancyServiceProvider.php

Tenancy

  • app/Tenancy/TenantContext.php
  • app/Models/Concerns/TenantOwned.php
  • app/Tenancy/Http/Middleware/Authenticate.php
  • app/Tenancy/Http/Middleware/ResolveTenant.php

Security / Auth / RBAC

  • RBAC:

    • app/Security/Rbac/PermissionChecker.php
    • app/Security/Rbac/GrantsRbacPermissions.php
    • app/Security/Rbac/GrantsRbacPermissionsTenant.php
  • Auth API:

    • app/Models/AuthResource.php
    • app/Dto/Auth/*
    • app/State/Auth/*
    • tests/Feature/Security/AuthApiTest.php

CRUD API (DTO + State layer)

  • DTOs:

    • app/Dto/{Tenant,Role,Permission,RolePermission,UserRole}/*
  • State:

    • app/State/{Tenant,Role,Permission,RolePermission,UserRole}/*

Eloquent Models + Factories

  • Models:

    • app/Models/{Tenant,Role,Permission,RolePermission,User,UserRole}.php
  • Factories:

    • database/factories/{Tenant,Role,Permission,RolePermission,UserRole}Factory.php

Database

  • Migrations:

    • database/migrations/0001...0006_*
  • Seeders:

    • database/seeders/{SecuritySeederTenant,DatabaseSeeder}.php

Tests

  • tests/Support/BaseApiTestCase.php
  • tests/Feature/*ApiTest.php

Notes

API Platform endpoints

If you generate API Platform resources, your documentation and endpoints depend on your api-platform configuration. Check config/api-platform.php and the generated resources under app/ApiResource.

Regenerating code

  • Use --dry-run to preview changes.
  • Use --force to overwrite files when you intentionally want to regenerate.

Versioning

SemVer tags: vMAJOR.MINOR.PATCH

License

See composer.json.

::contentReference[oaicite:0]{index=0}

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-01-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固