# CodeIgniter 4 Framework

## What is CodeIgniter?

CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure.
More information can be found at the [official site](https://codeigniter.com).

This repository holds the distributable version of the framework.
It has been built from the
[development repository](https://github.com/codeigniter4/CodeIgniter4).

More information about the plans for version 4 can be found in [CodeIgniter 4](https://forum.codeigniter.com/forumdisplay.php?fid=28) on the forums.

You can read the [user guide](https://codeigniter.com/user_guide/)
corresponding to the latest version of the framework.

## Important Change with index.php

`index.php` is no longer in the root of the project! It has been moved inside the *public* folder,
for better security and separation of components.

This means that you should configure your web server to "point" to your project's *public* folder, and
not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter *public/...*, as the rest of your logic and the
framework are exposed.

**Please** read the user guide for a better explanation of how CI4 works!

## Development Server Setup

The development base URL is
<http://192.168.30.106/php85/navnath/api_new.rebates.com/html/public/>.

This server uses PHP 8.5-FPM, running as `nginx`. That account must be able to
write to `writable/` for caching, logs, sessions, and uploads. After extracting
or replacing the project, run the following from the `html` directory as its
owner (requires the `setfacl` utility):

```sh
find writable -type d -exec setfacl -m u:nginx:rwx,d:u:nginx:rwx {} +
```

The default ACL also grants access to newly created runtime directories.
Do not make the entire project world-writable. A cache-directory permission
failure causes HTTP 500, and an unwritable logs directory prevents CodeIgniter
from recording the cause.

The default `php` CLI on this server is older than CodeIgniter supports.
Use PHP 8.5 explicitly for commands:

```sh
php8.5 spark routes
```

OpenResty/Nginx does not process `public/.htaccess`. Extensionless application
routes require a project-specific front-controller rule in the web server
configuration. On the current server even `index.php/path` is not forwarded
to PHP. An administrator must include
[`deployment/nginx-development.conf`](deployment/nginx-development.conf)
inside the existing development `server` block, validate the configuration,
and reload OpenResty. The snippet also blocks HTTP access outside `public/`.
It has not been installed into the root-owned server configuration.
The snippet was syntax-checked and exercised on a temporary localhost-only
OpenResty listener: API requests reached the application and returned the
expected unauthenticated JSON 401, public images returned 200, and nonpublic
paths and dotfiles were blocked. That temporary listener has been stopped.

## Application Migration

The application code was migrated from
`/var/www/php74/navnath/api_new.rebates.com/html` into
`/var/www/php85/navnath/api_new.rebates.com/html`. The installed CodeIgniter
4.7.5 `system/`, `public/index.php`, and `spark` were retained.

The migration includes all 17 source controllers, 15 models, 6 libraries,
6 filters, 3 helpers, application views, language files, database directories,
and public assets. The target's starter `Home` controller and current framework
error views remain in place. All 112 explicitly defined source routes, their
HTTP methods, handlers, and route filters are recorded in
[`tests/_support/Fixtures/legacy-routes.json`](tests/_support/Fixtures/legacy-routes.json)
and compared by the regression tests.

Compatibility decisions:

- The old host-dependent changes to the framework bootstrap now live in
  application configuration. Set `app.baseURL` explicitly, including its
  trailing slash. The existing target URL is preserved locally.
- Legacy auto-routing, filter ordering, traditional validation rules, and
  multi-segment wildcard arguments are retained to preserve API behavior.
  Changing these requires a separate API compatibility review.
- The source's America/Chicago timezone, one-day access-token lifetime,
  30-day refresh-token lifetime, and 30-day session expiration are preserved.
  The source encryption key is preserved privately, with a regression test
  for decrypting the CodeIgniter 4.1.5 payload format.
- The source `default`, `cms`, `stats`, and `keywords` database groups are
  configured through environment settings. During automated tests, **all four
  groups use the in-memory test database**, including models with an explicit
  `$DBGroup`.
- The new required page-cache filter is disabled for these authenticated APIs,
  so it cannot return a cached response before authentication runs.
- Missing property declarations, class/filename casing, authentication helper
  names, uppercase HTTP methods, and PHP 8.5's deprecated `curl_close()` calls
  were adapted.
- URL concatenation accounts for the newer `base_url()` trailing-slash behavior,
  retaining the source's development query-style links and asset URL paths.
- JWT, AWS S3, and PDF dependencies are managed by the target Composer
  manifest and lockfile, not the source's old vendor tree or the server-wide
  Composer autoloader.

### Local configuration

On this development server, the populated environment file is stored at
`/home/navnath/.config/rebates-api-php85/.env`, **outside `/var/www`**. The ignored
`app/Config/EnvironmentPath.php` returns that directory:

```php
<?php
return '/home/navnath/.config/rebates-api-php85';
```

`Config\Paths` loads this optional local pointer. Without it, CodeIgniter uses
the normal project-root `.env` location, which is suitable only when the web
server exposes `public/` exclusively. Do not copy credentials into the source
tree on this shared development server. The PHP-FPM account needs traversal
access to the private parent directories and read access to the private file,
but other users do not.

The [environment template](env) lists the application-specific keys. The local
file preserves existing integration settings; it does not provision sandbox
accounts. At the user's request, the local environment uses
`CI_ENVIRONMENT = development` to match the source bootstrap and development
URL behavior. Development errors may expose implementation details; restrict
access to this server and use production mode for a production deployment.
Integration credentials have been removed from migrated application source
files.

Install reproducible dependencies and validate with PHP 8.5:

```sh
php8.5 /usr/bin/composer install --no-interaction --prefer-dist
chmod -R a+rX vendor
php8.5 spark routes
php8.5 vendor/bin/phpunit --no-coverage
```

The read-permission step is needed here because some dependency archives
extract with group-only permissions; PHP-FPM runs under a different account.
For production deployment, install with `--no-dev`.

### Validation boundaries and outstanding dependencies

Migration regression tests check route/filter parity, controller loading,
response envelopes and status codes, API-key rejection, missing-token handling,
CORS preflight, validation without persistence, JWT claims and expiration,
referral cipher round trips, session settings, and test-database isolation.
No live database writes, Redis rate-limit writes, payments, emails, SMS,
uploads, or scheduled jobs are performed by those tests.

As requested, the external shared library tree remains at
`/var/www/php70/navnath/msacommon/lib/php/include/`, selected by
`legacy.sharedPath`. It was not copied or modified. CMS, coupon, search-feed,
and PayPal functionality still depends on that tree and its own configuration.
The cashback controller loads the legacy PayPal SDK through `PaypalSdk` only
when sending a payout or querying payout status, not when reading withdrawal
details. The loader excludes the SDK's bundled PSR-3 v1 namespace and configures
its supported custom logger factory to use the application's PSR-3 v3 logger.
SDK logging remains disabled unless `log.LogEnabled` is enabled; when enabled,
messages use CodeIgniter's log handlers and thresholds rather than the SDK's
`log.FileName` and `log.LogLevel`. No shared SDK files are changed. Live payout
behavior still requires sandbox acceptance testing.
Its `dbConstants.php` currently reports a malformed `arch_oci.ini` file and
subsequent array-offset warnings. The shared-library owner must resolve this
before the affected integrations can be certified under PHP 8.5.

Four source routes already point to methods absent from the source
`DashboardController`; they are preserved, not reimplemented speculatively:

- `GET dashboard/getBillingHistory`
- `POST dashboard/updateProfile`
- `POST dashboard/updatePassword`
- `POST dashboard/generateInvoice`

The `QLAuth` filter also refers to `ApiTokenModel` and `PublisherModel`, neither
of which is present in the supplied source. No explicit source route uses that
filter. The optional Twilio environment variables are not configured locally.

No application-specific cron files, commands, migrations, seeds, or matching
entries in the current user's crontab were found. The existing
`GET process-paypal-withdrawal` payout entry point is preserved but was **not
called or scheduled**. System-level or another user's schedules still need to
be supplied by their owner for a complete scheduled-task inventory.

**Release gates:** install the Nginx routing snippet, resolve external shared
configuration, clarify the four missing source handlers, provide any missing
integration settings and schedules, then run end-to-end acceptance tests using
isolated databases and sandbox integrations. Passing the offline suite does
not certify live transaction flows.

## Repository Management

We use GitHub issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages.
We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss
FEATURE REQUESTS.

This repository is a "distribution" one, built by our release preparation script.
Problems with it can be raised on our forum, or as issues in the main repository.

## Contributing

We welcome contributions from the community.

Please read the [*Contributing to CodeIgniter*](https://github.com/codeigniter4/CodeIgniter4/blob/develop/CONTRIBUTING.md) section in the development repository.

## Server Requirements

PHP version 8.2 or higher is required, with the following extensions installed:

- [intl](http://php.net/manual/en/intl.requirements.php)
- [mbstring](http://php.net/manual/en/mbstring.installation.php)

> [!WARNING]
> - The end of life date for PHP 7.4 was November 28, 2022.
> - The end of life date for PHP 8.0 was November 26, 2023.
> - The end of life date for PHP 8.1 was December 31, 2025.
> - If you are still using below PHP 8.2, you should upgrade immediately.
> - The end of life date for PHP 8.2 will be December 31, 2026.

Additionally, make sure that the following extensions are enabled in your PHP:

- json (enabled by default - don't turn it off)
- [mysqlnd](http://php.net/manual/en/mysqlnd.install.php) if you plan to use MySQL
- [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library
