Download the PHP package mrnaeem4/ci3-request-analysis without Composer

On this page you can find all versions of the php package mrnaeem4/ci3-request-analysis. 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 ci3-request-analysis

ci3-request-analysis

CodeIgniter 3 hook that intercepts incoming HTTP requests, extracts structured metadata (headers, body, files, tenant, source IP, etc.), and writes one JSON Line per request directly to the CI3 application/logs directory — with sensitive-field redaction, body truncation, IP whitelisting, and daily log rotation with gzip compression.

Local logging only. No external server, no queue, no Guzzle. This is the CI3 counterpart of ci4-request-analysis.

Features

Requirements

Installation

Custom vendor-dir: If your composer.json sets "vendor-dir" (e.g. application/third_party/vendor), the package installs there. That is fine — just point $config['composer_autoload'] at that exact vendor/autoload.php path. CodeIgniter's TRUE shortcut only looks at application/vendor/ and the project root.

If you do not use Composer, add a PSR-4 autoloader mapping MrNaeem\Ci3RequestAnalysis\ to the src/ directory, or require the three classes manually:

Configuration

1. Enable hooks + Composer autoload

In application/config/config.php:

2. Register the hook

Important: CI3's array hook format (class/function/filename/ filepath) cannot resolve Composer namespaced classes — CI_Hooks::_run_hook() checks class_exists($class, false) (no autoload) and then require_onces the filepath/filename, which fails for vendor files. Use a closure instead (CI3 supports callables natively):

In application/config/hooks.php:

3. Load the .env file

CI3 does not parse a .env file by itself, and the config values are read with getenv(). Without loading the file, REQUEST_LOG_ENABLED is empty and the hook silently does nothing. Pick one:

Option A — vlucas/phpdotenv (recommended):

Load it in index.php (the front controller) before requiring CodeIgniter.php:

Option B — Apache SetEnv:

Option C — Nginx fastcgi_param:

4. Set environment variables

Values of the .env file (or server env):

Config reference

Variable Default Description
REQUEST_LOG_ENABLED false Master switch for the hook.
REQUEST_LOG_DIR '' (→ application/logs) Directory for the log file.
REQUEST_LOG_FILE analysis.log Log file name (single file, rotated daily).
REQUEST_LOG_REDACT_FIELDS password,nik,Api-Key,no_telp Comma-separated sensitive fields (case-insensitive).
REQUEST_LOG_MAX_BODY_SIZE 3145728 (3 MB) raw_body truncation length (bytes).
REQUEST_LOG_WHITELIST_IPS RFC1918 + localhost CIDR ranges to skip.
REQUEST_LOG_TRUNCATE_SUFFIX ... [truncated] Appended when the body is truncated.
REQUEST_LOG_RETENTION_DAYS 30 Days of compressed logs kept before pruning.
REQUEST_LOG_METHODS '' (all) Comma-separated HTTP methods to log (e.g. POST,PUT).
REQUEST_LOG_INCLUDE_PATHS '' (all) Regex allow-list for request paths (comma-separated).
REQUEST_LOG_EXCLUDE_PATHS '' (none) Regex deny-list for request paths (comma-separated).

Path & method filtering

By default every request (including GET /) is logged. Restrict it:

Patterns are regex matched against the request path (e.g. /api/upload). includePaths is evaluated first; a request must match at least one include pattern when that list is non-empty. excludePaths wins afterwards.

Log payload

Each line in analysis.log is a JSON object (envelope + log_data):

How it works

The write is a single append with LOCK_EX, so it does not block the request and is safe for concurrent PHP-FPM workers.

Security

CI3 places index.php in the same directory as application/, so by default everything under application/ — including application/logs/analysis.log, which contains request headers and bodies — is reachable directly from the browser (http://host/application/logs/analysis.log). Apply at least one of the layers below; using all three is recommended.

1. Keep application/ out of the web root (recommended)

Move the front controller so the public web root only contains index.php, .htaccess and assets:

Then fix the paths in public/index.php (a copy of the original, with $system_path/$application_folder updated to ../system and ../application) and set $config['base_url'] accordingly in application/config/config.php.

2. Redirect the log directory outside the web root

Even with the default layout, point logs somewhere the browser cannot reach:

The hook falls back to application/logs only when REQUEST_LOG_DIR is empty.

3. Deny access with the web server

Apache — ship an .htaccess inside the log directory (and the application/ directory) with:

The sample app already includes sample/application/logs/.htaccess and sample/application/uploads/.htaccess. If AllowOverride is disabled, deny the paths in the vhost instead:

Nginx:

Laravel-style check — as a last line of defense, application/logs/.htaccess also rejects *.log / *.gz matches even if directory-level rules are ignored.

Notes

Sample app

A minimal CI3 application fragment lives under sample/:

Copy the relevant files into an existing CI3 application and start your server.

Changelog

See CHANGELOG.md.

License

MIT


All versions of ci3-request-analysis with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 mrnaeem4/ci3-request-analysis contains the following files

Loading the files please wait ...