Download the PHP package yahyaerturan/audit-codeigniter4 without Composer

On this page you can find all versions of the php package yahyaerturan/audit-codeigniter4. 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 audit-codeigniter4

yahyaerturan/audit — CodeIgniter 4 adapter

CodeIgniter 4 integration for the framework-neutral yahyaerturan/audit immutable audit-trail library. The adapter holds all CI4 coupling so the core package stays free of any framework dependency.


Requirements

Requirement Version
PHP ^8.5
CodeIgniter codeigniter4/framework ^4.7
Core library yahyaerturan/audit ^2.0 (installed automatically)
Extensions ext-json
Database SQLite3 or PostgreSQL (see Supported databases)

The PHP floor is deliberately narrower than CodeIgniter's own: CI4 4.7 supports PHP 8.2+, whereas this adapter and the core library require PHP 8.5. The constraints still intersect cleanly (^8.5 ∩ ^8.2 → >=8.5 <9.0), but an application still running PHP 8.3 or 8.4 cannot install 2.0.0. For that case 1.0.0 remains published on the ^8.3 floor, and Composer selects it automatically when the platform does not satisfy ^8.5.


Installation

On PHP 8.3 or 8.4, pin the last release built for that floor (it pulls the core at ^1.0):

The package is discovered automatically through Composer's PSR-4 map: CI4 finds its Config\Services, Config\Registrar, and Commands without any manual registration, as long as module discovery stays enabled (the framework default).


Configuration

All knobs live on YahyaErturan\Audit\CodeIgniter4\Config\Audit. They are intentionally coarse and scalar — richer behavior (actor resolution, tenancy, redaction) is customized by overriding a service, not by growing this class.

Property Type Default Purpose
databaseGroup string default CI4 database group whose connection the audit store wraps. Use your app's group to couple writes to its transaction, or a dedicated group for independent persistence.
captureRequestMethod bool true Capture the request.method metadata key on HTTP requests.
captureRequestPath bool true Capture request.path (query string excluded) on HTTP requests.
captureIpAddress bool false Capture request.ip. Off by default for privacy.
captureUserAgent bool false Capture request.user_agent. Off by default for privacy.
acceptIncomingCorrelationId bool false Trust a validated upstream correlation header. Read only by the opt-in filter; never trusted implicitly.
incomingCorrelationHeader string X-Correlation-ID Header read for an incoming correlation ID when the above is true.
metadataMaxBytes int 65536 Maximum serialized metadata bytes (mirrors the core default).
changesMaxBytes int 262144 Maximum serialized changes bytes (mirrors the core default).

Because the class extends CodeIgniter\Config\BaseConfig, override values through .env (short prefix audit) or an application Registrar — you do not edit the package file.

.env

Registrar (app/Config/Registrar.php)


Create the schema

Two Spark commands manage the audit tables on the configured databaseGroup:


Recording an entry

Resolve the recorder with service('yahyaAuditRecorder') and submit an immutable AuditRecord:

The recorder fills the actor, tenant, correlation ID, request ID, and request metadata from the current request context, normalizes and redacts changes/metadata, assigns a UUIDv7 id and a recorded-at timestamp, appends exactly once, and returns the immutable AuditEntry. It retains no per-request state, so sharing it across sequential requests in a long-running worker cannot leak one request's actor/tenant/trace into the next.

AuditRecord is a fluent, immutable builder — every method returns a new instance. Available methods: for(), by(), on(), withChanges(), withMetadata(), withTenantId(), withCorrelationId(), withCausationId(), withRequestId(), occurredAt().


Reading and querying

Resolve the reader with service('yahyaAuditReader'):

There is deliberately no count() and no offset pagination: totals are expensive on very large audit tables and encourage offset UX. AuditPage exposes entries(), nextCursor(), and hasMore(); pass the opaque cursor back through after() unchanged.

AuditQuery modifiers: forTenant() / withoutTenant() / anyTenant(), forEvent() / eventPrefix(), byActor(), forSubject(), withCorrelationId() / withCausationId() / withRequestId(), since() / until(), forIds(), limit() (1–500, default 100), after().


Transaction semantics

The store never owns the business transaction. append() never begins, commits, or rolls back on its own — it executes its insert on the connection it is given. Point databaseGroup at the same group your application uses and the audit append becomes part of your transaction:

Use a dedicated group when the audit record must survive even if the business transaction rolls back (independent persistence). Both the rollback and the commit case are covered by the adapter's integration tests.


Actor and tenant resolution

The adapter never depends on Shield or any authentication library. Out of the box:

Attribute entries to real users/tenants by overriding the matching service in your application's app/Config/Services.php (CI4 discovers it with application-namespace precedence):

Your resolver implements ActorResolver::resolve(): Actor and receives nothing from the framework automatically — inject your own dependencies (for example Shield's auth()) and return an Actor. For tenancy, override yahyaAuditTenantResolver (returning TenantResolver::resolve(): ?string), or set a tenant per record with ->withTenantId('acme').


Optional request-context filter (audit-context)

Installing the package registers the audit-context filter alias (via its Registrar), but the filter is never global and never runs at boot. Attach it explicitly to routes or groups to stamp each HTTP request with adapter-private trace markers before your application runs:

The filter writes two spoof-proof headers — it removes each header before re-setting it, so a client cannot inject or duplicate them:

Header Value
X-Yahya-Audit-Request-Id a fresh UUIDv7 per request
X-Yahya-Audit-Correlation-Id a fresh UUIDv7, or a validated upstream value when acceptIncomingCorrelationId is true and incomingCorrelationHeader is present and valid

The context provider later reads these markers into each recorded entry's requestId / correlationId. The filter records nothing and never mutates the response. Without the filter the recorder still works — those two identifiers are simply null.


Supported databases

CI4 platform Core driver Status
SQLite3 sqlite supported
Postgre postgresql supported
any other (MySQLi, SQLSRV, OCI8, …) — rejected at construction with UnsupportedDatabaseDriver

The bridge issues raw SQL with positional ? binds and never uses the query builder, so the group's DBPrefix is not applied to audit statements — the schema owns its table names.


Failure behavior

Nothing is silently swallowed. The adapter translates CI4's two failure modes (a thrown DatabaseException, or query() returning false with a connection error) into core audit exceptions, all of which implement the AuditException marker:

Condition Exception
Unsupported database platform UnsupportedDatabaseDriver
Transaction begin/commit/rollback failed AuditPersistenceFailed
Insert/statement failed AuditPersistenceFailed
Duplicate entry id (unique violation) DuplicateAuditEntryId
Invalid value (oversize metadata/changes, bad ids) InvalidAuditValue / InvalidAuditIdentifier
Invalid query InvalidAuditQuery
Invalid cursor InvalidAuditCursor

Because the store never owns the transaction, a thrown exception leaves the surrounding transaction for your code to roll back.


Services reference

Resolve any service with service('...'). Each is shared and safe to reuse across requests.

Service key Contract Responsibility
yahyaAuditRecorder Auditor record(AuditRecord): AuditEntry
yahyaAuditReader AuditReader find() / search()
yahyaAuditStore AuditStore append-only writer
yahyaAuditSqlConnection SqlConnection wraps the configured group's connection
yahyaAuditSchemaManager AuditSchemaManager schema migrate/status
yahyaAuditContextProvider AuditContextProvider builds the per-request context
yahyaAuditActorResolver ActorResolver override to attribute real users
yahyaAuditTenantResolver TenantResolver override for tenancy
yahyaAuditRequestAccessor RequestAccessor current-request seam

Service names are yahyaAudit*-prefixed because CI4 discovers service methods globally and unprefixed names would collide across packages.


License

MIT — see LICENSE.


All versions of audit-codeigniter4 with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ext-json Version *
yahyaerturan/audit Version ^2.0
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 yahyaerturan/audit-codeigniter4 contains the following files

Loading the files please wait ...