Download the PHP package dcardenasl/ci4-api-scaffolding without Composer

On this page you can find all versions of the php package dcardenasl/ci4-api-scaffolding. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ci4-api-scaffolding

ci4-api-scaffolding

CI PHP CI4 Latest Stable Version Total Downloads

CRUD scaffolding engine for CodeIgniter 4 APIs built on dcardenasl/ci4-api-core. One command generates DTOs, service, controller, migration, routes, language files, and tests — all wired to the ci4-api-core base classes.

Pre-1.0 policy: MINOR bumps may contain breaking changes. Pin to ~0.x.0 or exact version until v1.0.0.

Table of Contents

Requirements

Installation

Quick Start

Configuration

Create app/Config/Scaffolding.php extending BaseScaffoldingConfig. If your project follows ci4-api-starter conventions, the bundled defaults work without any overrides:

To customize base classes, paths, or route filters, pass named arguments to ScaffoldingConfig:

Default route filters (when no Scaffolding config is found): ['jwtauth', 'permission:iam.superadmin-access', 'throttle']. New resources are unreachable by non-superadmins until you intentionally loosen this filter.

All configurable options (ScaffoldingConfig constructor parameters):

Option Default Purpose
controllerBaseClass dcardenasl\Ci4ApiCore\Http\ApiController Base class generated controllers extend
serviceBaseClass dcardenasl\Ci4ApiCore\Services\BaseCrudService Base class generated services extend
requestDtoBaseClass dcardenasl\Ci4ApiCore\Dto\BaseRequestDTO Base class generated request DTOs extend
responseDtoInterface dcardenasl\Ci4ApiCore\Dto\DataTransferObjectInterface Interface response DTOs implement
modelBaseClass dcardenasl\Ci4ApiCore\Models\BaseAuditableModel Base class generated models extend
protectedRouteFilters ['jwtauth', 'permission:iam.superadmin-access', 'throttle'] Filters on the protected route group
appNamespace App Top-level namespace of the consumer app
paths ScaffoldingPaths::defaults() All output directories (see ScaffoldingPaths)
openApiTagPrefix null (uses domain name) Custom OpenAPI tag prefix
conditionalControllerTraits [] fieldName => TraitFQCN map for auto-injected controller traits

Path overrides (ScaffoldingPaths constructor parameters, all relative to APPPATH):

Option Default
controllers Controllers/Api/V1
services Services
interfaces Interfaces
requestDtos DTO/Request
responseDtos DTO/Response
models Models
entities Entities
migrations Database/Migrations
routes Config/Routes/v1
documentation Documentation
languageEn Language/en
languageEs Language/es
unitTests tests/Unit/Services (relative to ROOTPATH)
integrationTests tests/Integration/Models (relative to ROOTPATH)
featureTests tests/Feature/Controllers (relative to ROOTPATH)

Available Commands

Command Shell wrapper Description
php spark make:crud bash vendor/bin/make-crud.sh Generate a full CRUD module
php spark make:crud:remove Remove a previously scaffolded module
php spark module:check bash vendor/bin/validate-crud.sh Validate 14 post-scaffold wiring checkpoints
php spark scaffold:check Verify Config\Scaffolding exists and all FQCNs resolve
php spark swagger:generate Generate public/swagger.json from OpenAPI annotations

Always use vendor/bin/make-crud.sh in non-TTY environments (CI, Claude Code, scripts). php spark make:crud falls back to interactive mode when --fields is not provided, which hangs in non-TTY contexts.

make:crud — full options

Option Default Purpose
--domain / arg 2 Catalog Domain folder (groups related resources)
--fields / arg 3 interactive Field definition string (see Field Types)
--route / arg 5 kebab-case plural of resource Route slug used in the URL
--soft-delete / arg 4 yes Emit deleted_at column and soft-delete logic
--version v1 Target a versioned route directory (e.g. --version v2 writes routes to Config/Routes/v2/)
--dry-run off Preview planned files and wiring without writing anything
--no-wire off Generate files but skip Services.php injection; prints snippets to paste manually
--skip-fk-validation off Skip the FK target existence check when the database is unreachable
--migrate (wrapper only) off Auto-run php spark migrate after scaffolding

make:crud:remove — full options

--force skips the confirmation prompt (useful in CI). Without --force, the command lists the files it would delete and asks for confirmation.

module:check / validate-crud.sh

Validates 14 post-scaffold wiring checkpoints: migration exists, table naming, soft-delete consistency, controller/model/service/route presence, Services.php wiring, language files, test files. Exits non-zero if any checkpoint fails.

scaffold:check

Read-only diagnostic — never writes files. Verifies that app/Config/Scaffolding.php exists, extends BaseScaffoldingConfig, and that all 14 FQCNs it declares (base classes, interfaces, traits) are loadable. Run after first install or after bumping dcardenasl/ci4-api-core to confirm the config still points at real classes.

If the file is missing, the command prints the cp command to bootstrap a default config from the bundled example.

swagger:generate

Generates public/swagger.json from OpenAPI annotations. Scans app/Config/OpenApi.php, app/Controllers/, app/Documentation/, app/DTO/, and vendor/dcardenasl/ci4-api-core/src/Dto/ by default. Requires zircote/swagger-php in the consumer's require-dev:

To scan additional directories, subclass the command and override scanPaths():

Field Types

Field type codes used in the --fields string. All types are recognized case-sensitively.

Type Alias PHP type DB column OpenAPI Validation (auto-added)
string string VARCHAR(255) string string\|max_length[255]
text string TEXT string string
int integer int INT integer integer
decimal float DECIMAL(10,2) number (float) decimal
bool bool TINYINT(1) boolean boolean_like
email string VARCHAR(255) string (email) string\|valid_email\|max_length[255]
date string DATE string (date) valid_date[Y-m-d]
datetime string DATETIME string (date-time) valid_date
json array JSON object permit_empty
fk relation int INT + FK constraint integer is_natural_no_zero\|is_not_unique[table.id]

FK field syntax — uses a 4-segment form because the target table name is a required third segment:

Field Modifiers

Modifiers follow the type (or the FK table) and are separated by |:

Modifier Effect
required required validation rule; non-nullable column
nullable Nullable column; permit_empty validation rule
searchable Adds FULLTEXT index; controller gets HasSearchableIndex trait
filterable Adds field to the model's $filterableFields whitelist
unique Adds UNIQUE index + is_unique[table.column] validation
index Adds a plain (non-unique) index
cascade FK/relation only — ON DELETE CASCADE (default for fk and relation fields)
restrict FK/relation only — ON DELETE RESTRICT
setnull FK/relation only — ON DELETE SET NULL

Full example:

Boolean validation contractbool currently maps to boolean_like, which is part of the supported starter contract (ci4-api-starter and ci4-domain-starter both ship and register that custom rule). If a non-starter consumer uses this package, it must expose an equivalent boolean_like validation rule or adapt the generated rule set after scaffolding.

Generated Artifacts

make:crud Article Blog 'title:string:required' yes creates 17 files:

Services.php is also updated (or a snippet is printed with --no-wire) to register the new service and response mapper.

Scaffolding Boundaries

make:crud is designed for flat CRUD resources. It gives you a correct starting module for entities that behave like:

It is not a full aggregate generator. If your resource needs any of the following, expect manual extension after scaffolding:

Practical rule:

The scaffolder is successful when it removes boilerplate and preserves architectural consistency. It is not trying to replace domain modeling for complex aggregates.

CSV export/import is intentionally outside the upstream API scaffold contract. In this workspace, that admin-facing bulk workflow lives in ci4-admin-starter, where the generator can align the export route with the current index filters and surface import validation in the admin UI.

Compatibility Matrix

PHP 8.2 PHP 8.3 PHP 8.4
CI4 4.7.* ✅*

* PHP 8.4 is tested against the locked CI4 version in the test job. The explicit CI4-compatibility matrix covers PHP 8.2 and 8.3. CI4 4.5.x and 4.6.x were dropped: 4.5.x for security advisories, 4.6.x because v0.3.2 widened the floor to ^4.7.

CI runs on every push: PHPStan level 8, PHP CS Fixer, full unit suite, E2E smoke test (creates a real CI4 project and scaffolds into it). PHP 8.2 additionally collects coverage.

Development

For architecture constraints that generated code must satisfy, see docs/ARCHITECTURE_CONTRACT.md.

Troubleshooting

--fields is empty / scaffold produces a partial module Always single-quote the fields string. Unquoted pipes (|) are consumed by the shell before the command sees them:

php spark make:crud hangs in a script / CI It entered interactive mode because --fields was empty and stdin is not a TTY. Use vendor/bin/make-crud.sh instead, which guards against this and requires --fields in non-TTY contexts.

Wiring failed / Services.php was not modified The ConfigWireman uses AST-based injection and expects Services.php to follow the CI4 convention (a class with static factory methods in a trait). Run with --no-wire to get the snippet to paste manually:

FK validation aborts because the DB is unreachable Pass --skip-fk-validation when you know the target tables exist but the DB isn't available (e.g. in a fresh setup before migrate):

Scaffolded routes don't appear in php spark routes:list New route files are not hot-reloaded. Restart the server after scaffolding:

module:check fails on a valid module Run php spark module:check <Resource> --domain <Domain> to see which of the 14 checkpoints failed and why.

Example Project

ci4-api-core-example is a complete, runnable Catalog API (Categories + Products) built entirely with this scaffolding engine — minimal hand-written code. Each step is a separate git commit so you can trace exactly what make-crud.sh generates, from a blank CI4 project to a production-ready API with filtering, searching, pagination, and OpenAPI docs.

License

MIT — see LICENSE.


All versions of ci4-api-scaffolding with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
dcardenasl/ci4-api-core Version ^1.0
codeigniter4/framework Version ^4.7
nikic/php-parser Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dcardenasl/ci4-api-scaffolding contains the following files

Loading the files please wait ...