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/laravelis installed)
- PHP 8.2+
- Laravel 10 / 11 / 12
cnd-api-maker/core- (optional)
api-platform/laravelif you generate API Platform resources
composer require cnd-api-maker/laravelIn 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/laravelAuto-discovery is enabled via:
"extra": {
"laravel": {
"providers": [
"CndApiMaker\\Laravel\\ApiPlatformMakerServiceProvider"
]
}
}If auto-discovery is disabled, register the provider manually in config/app.php.
- 1 create a laravel project
composer create-project laravel/laravel starter-laravel
- 2 create a laravel project
composer require cnd-api-maker/laravel
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:
php artisan cnd:api-maker:install --forcephp artisan cnd:api-maker:generate --file=example.jdlCommon options (depending on your implementation):
--forceoverwrite generated files--dry-runpreview without writing--module=...generate into a specific module/namespace (if supported)
php artisan migrate
php artisan testapp/ApiResource/Health.phpconfig/api-platform.phpbootstrap/app.phpbootstrap/providers.php
app/Console/Commands/GeneratePermissionsCommand.phpapp/Providers/TenancyServiceProvider.php
app/Tenancy/TenantContext.phpapp/Models/Concerns/TenantOwned.phpapp/Tenancy/Http/Middleware/Authenticate.phpapp/Tenancy/Http/Middleware/ResolveTenant.php
-
RBAC:
app/Security/Rbac/PermissionChecker.phpapp/Security/Rbac/GrantsRbacPermissions.phpapp/Security/Rbac/GrantsRbacPermissionsTenant.php
-
Auth API:
app/Models/AuthResource.phpapp/Dto/Auth/*app/State/Auth/*tests/Feature/Security/AuthApiTest.php
-
DTOs:
app/Dto/{Tenant,Role,Permission,RolePermission,UserRole}/*
-
State:
app/State/{Tenant,Role,Permission,RolePermission,UserRole}/*
-
Models:
app/Models/{Tenant,Role,Permission,RolePermission,User,UserRole}.php
-
Factories:
database/factories/{Tenant,Role,Permission,RolePermission,UserRole}Factory.php
-
Migrations:
database/migrations/0001...0006_*
-
Seeders:
database/seeders/{SecuritySeederTenant,DatabaseSeeder}.php
tests/Support/BaseApiTestCase.phptests/Feature/*ApiTest.php
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.
- Use
--dry-runto preview changes. - Use
--forceto overwrite files when you intentionally want to regenerate.
SemVer tags: vMAJOR.MINOR.PATCH
See composer.json.
::contentReference[oaicite:0]{index=0}