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

On this page you can find all versions of the php package dcardenasl/ci4-api-core. 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-core

ci4-api-core

CI Coverage

DTO-first API runtime foundation for CodeIgniter 4: base classes, HTTP layer, services, repositories, filters, audit chain, and queue. Drop into any CodeIgniter 4 project. Pair with dcardenasl/ci4-api-scaffolding for CRUD generation.

Status: v0.4.x (pre-release) — published on Packagist. APIs may still change before 1.0.0. Pin to ~0.4.0 or an exact version in production until 1.0.

Contents

Quick Start

What it does

Package boundary: ci4-api-core provides the runtime foundation — base classes, HTTP layer, services, repositories, models, filters, audit chain, queue, and security utilities. The scaffolding engine (generators, make-crud.sh, spark commands) lives in the companion package dcardenasl/ci4-api-scaffolding. The flowchart below shows the full system when both packages are installed.

Generates a complete, production-ready CRUD module from a single command:

Outputs:

Why a package

The engine was being copied between projects manually, leading to drift. Extracting it gives:

Runtime foundation

ci4-api-core ships the classes that generated (and hand-written) modules extend and depend on at runtime:

Layer Key classes
HTTP ApiController (handleRequest() pipeline), ApiRequest, ApiResponse, ContextHolder, RequestIdHolder
HTTP filters CorsFilter, CorrelationIdFilter, IdempotencyFilter, LocaleFilter, MaintenanceFilter, RequestLoggingFilter, DeprecationHeadersFilter, FeatureToggleFilter
DTOs BaseRequestDTO (auto-validation), PaginatedResponseDTO, DataTransferObjectInterface, SecurityContext
Services BaseCrudService, CrudServiceContract, HandlesTransactions trait, AuditService, AuditServiceInterface, NullAuditService
Repositories RepositoryInterface, GenericRepository, BaseRepository, AuditRepositoryInterface
Models BaseAuditableModel, Auditable trait, Filterable trait, Searchable trait, DecimalCast
Query layer FilterParser, FilterOperatorApplier, SearchQueryApplier, QueryBuilder
Exceptions ApiException + NotFoundException, ValidationException, BadRequestException, AuthenticationException, AuthorizationException, ConflictException, ServiceUnavailableException, TooManyRequestsException
Support OperationResult, OperationState enum, ApiResult, ExceptionFormatter, ApiConfigFacade · RelationLabelLoader (batch label loading, no N+1) · CacheHelper (cache-aside in one line) · DateHelper (null-safe date normalisation) — see docs/SUPPORT_UTILITIES.md
Security Security\Hasher, Security\Token, Security\Mask
Queue QueueManager, SyncQueueManager, Job base, WriteAuditLogJob, LogRequestJob
Logging JsonFormatter, MonologHandler

Requirements

Installation

Configure

Runtime — Config\Api (optional)

ci4-api-core reads an optional Config\Api class for search and pagination knobs. Defaults are safe when absent:

Scaffolding — Config\Scaffolding (ci4-api-scaffolding)

Create app/Config/Scaffolding.php in your project. If your project follows the default conventions exactly, a one-liner is sufficient:

If omitted, the spark commands fall back to ScaffoldingConfig::defaults() with a warning.

Wiring — php spark core:install

After adding the package, run the wiring wizard to inject the required service factories into app/Config/Services.php:

The command detects which of the 4 required factories are already present and generates only the missing stubs. Re-running against an already-wired project is a no-op.

Usage

Scaffold a new CRUD module

Always wrap <Fields> in single quotes — the | modifier separator is shell-special.

Options

Flag Effect
--dry-run Preview the planned file list and wiring snippets without writing anything.
--no-wire Skip auto-injection into Config/Services.php; print the snippets for manual paste.

Validate and apply

After scaffolding, run in order:

Remove a module

Deletes all generated artifacts and un-wires the service registration.

Field syntax

Format: name:type:modifier1|modifier2

Supported types:

Type Database column PHP type
string VARCHAR(255) string
text TEXT string
int INT UNSIGNED int
decimal DECIMAL(10,2) float
bool TINYINT(1) bool
email VARCHAR(255) string
date DATE string
datetime DATETIME string
json JSON array
fk:table INT UNSIGNED + FK int

Supported modifiers:

Modifier Effect
required NOT NULL + required validation rule
nullable NULL + permit_empty validation rule
searchable Included in ?search= (LIKE); adds B-tree index
filterable Included in ?filter[col]= (exact match); adds B-tree index
unique UNIQUE index + is_unique[table.col] on the Create DTO
index Non-unique B-tree index
fk:table Foreign key to table.id + is_not_unique[table.id] validation

Invalid or reserved field names are rejected upfront (PHP keywords, MySQL reserved words, id, created_at, updated_at, deleted_at).

Scope and limitations (v0.x)

The generator is designed for flat resources: one resource = one table = one set of CRUD endpoints. This is intentional — most domain entities are flat, and "smart" relation handling tends to over-engineer the simple case.

What fk:<table> does today:

What it does NOT do — wire by hand if you need it:

If your domain needs any of the above, scaffold both resources flat first, then hand-edit the Service / Response DTO of the parent to load and expose the child collection. This is rarely more than ~30 lines of code per relation, and keeps the generator's surface small enough to remain stable across versions.

Roadmap: relation-aware generators are tracked in ci4-api-scaffolding's backlog (CRUD-003). The pre-1.0 API may still change.

Customization

Override any convention by passing a customized ScaffoldingConfig from your build() method:

ScaffoldingPaths defaults (relative to APPPATH, except tests which are relative to ROOTPATH):

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

Scaffolding contract

The engine generates code that extends specific base classes. Your project must provide these (or override them in Config\Scaffolding):

Symbol Default FQCN Purpose
Controller base App\Controllers\ApiController handleRequest() pipeline
Service base App\Services\Core\BaseCrudService CRUD lifecycle
Service interface App\Interfaces\Core\CrudServiceContract Type contract
Model base App\Models\BaseAuditableModel created_by / updated_by audit
Request DTO base App\DTO\Request\BaseRequestDTO Auto-validation
Response DTO interface App\Interfaces\DataTransferObjectInterface Response shape
Repository interface App\Interfaces\Core\RepositoryInterface Generic persistence
Repository impl App\Repositories\GenericRepository Default CRUD impl
Response mapper interface App\Interfaces\Mappers\ResponseMapperInterface DTO mapping
Response mapper impl App\Services\Core\Mappers\DtoResponseMapper Default mapper

These are the defaults in ScaffoldingConfig::defaults().

Wiring assumption

ConfigWireman (the auto-wiring component) uses regex injection against app/Config/Services.php. It looks for a trait import line matching use {Domain}DomainServices; and injects the new service factory method there. If your Services.php has a non-standard layout, pass --no-wire and paste the printed snippet manually.

Troubleshooting

php spark make:crud prompted me for fields even though I passed --fields='…' You're in a non-TTY environment and the shell consumed the pipe characters. Use vendor/bin/make-crud.sh — it handles quoting correctly and is safe in CI and automation scripts.

Routes return 404 after scaffolding CI4 loads route files at boot only. Restart the server:

ScaffoldConflictException: files already exist Artifacts from a previous scaffold are still on disk. Either migrate + commit the previous module, or remove the stale files and try again. The orchestrator rolls back partial writes on failure, so the conflict is always pre-existing state, not a failed run.

Pre-commit hook rejects generated files vendor/bin/make-crud.sh runs composer cs-fix automatically post-generation. If you used php spark make:crud directly:

Never skip with --no-verify.

Auto-wiring silently skipped The commands fall back to --no-wire behaviour if they cannot locate the trait import line. Check the output — it will print the snippet for manual paste. Use --no-wire explicitly if your Services.php layout differs from the default.

See also

Toward 1.0

What is stable today

The following surfaces have integration tests and are considered stable. Changes here will carry a BREAKING tag in the changelog.

Area Stable classes / interfaces
HTTP layer ApiController, ApiRequest, ApiResponse, ContextHolder, RequestIdHolder
Exception hierarchy ApiException + all 8 concrete exceptions, ExceptionFormatter
DTO contracts DataTransferObjectInterface, BaseRequestDTO, PaginatedResponseDTO, SecurityContext
Repository contract RepositoryInterface, BaseRepository, GenericRepository
Audit chain AuditService, AuditWriter, AuditPayloadSanitizer, AuditServiceInterface, NullAuditService
Queue contract QueueManager, SyncQueueManager, Job, WriteAuditLogJob
Security utilities Security\Hasher, Security\Token, Security\Mask
Concrete filters (9) CorrelationIdFilter, CorsFilter, SecurityHeadersFilter, FeatureToggleFilter, IdempotencyFilter, LocaleFilter, MaintenanceFilter, RequestLoggingFilter, DeprecationHeadersFilter
Abstract filter bases (3) AbstractJwtAuthFilter, AbstractPermissionFilter, AbstractThrottleFilter

What may still change before 1.0

Surface Likelihood Notes
BaseCrudService hook signatures (beforeStore, afterUpdate, etc.) Low Signature is clean, but exact parameter set may gain a $context overload
HealthChecker constructor Medium Planned: accept an injected BaseConnection so it is testable without a live DB connection
IAM hook surface (AbstractIamAuthorizationService) Medium May gain a standardized resolvePermissions() contract before 1.0

Criteria for 1.0.0

  1. All stable-surface classes have integration tests with verified behavior.
  2. HealthChecker accepts an injected BaseConnection — testable without a live database.
  3. At least one documented real-world consumer running in production.
  4. Infection PHP Mutation Score Indicator (MSI) ≥ 80% across the Unit + Integration suite.
  5. No open BREAKING items in CHANGELOG.md [Unreleased].

Development

Tests run without bootstrapping a CI4 app — tests/bootstrap.php defines the minimum APPPATH/ROOTPATH shims.

License

MIT — see LICENSE.


All versions of ci4-api-core with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
codeigniter4/framework Version ^4.7
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-core contains the following files

Loading the files please wait ...