Download the PHP package ctw/ctw-middleware-phpconfig without Composer

On this page you can find all versions of the php package ctw/ctw-middleware-phpconfig. 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 ctw-middleware-phpconfig

Package "ctw/ctw-middleware-phpconfig"

Latest Stable Version GitHub Actions

PSR-15 middleware that sets PHP configuration options at runtime from application configuration files.

Introduction

Why This Library Exists

PHP applications often require specific php.ini settings that differ from server defaults. While these can be set in the server's php.ini or .htaccess files, managing settings at the application level provides several advantages:

This middleware applies PHP configuration settings early in the request lifecycle, ensuring all subsequent code operates with the correct settings.

Problems This Library Solves

  1. Server dependency: Relying on server administrators to configure php.ini correctly
  2. Configuration drift: Settings differ between environments without version control
  3. Shared hosting limits: Many hosts restrict php.ini modifications
  4. Scattered configuration: PHP settings in .htaccess, php.ini, and code are hard to track
  5. Environment-specific needs: Development needs different settings than production

Where to Use This Library

Design Goals

  1. Configuration-driven: Settings come from application config arrays, not hardcoded
  2. Type normalization: Converts booleans to On/Off, integers to strings automatically
  3. Fail-fast validation: Throws exceptions for invalid or unchangeable options
  4. Early execution: Apply settings before other middleware processes requests
  5. Transparent operation: No modification to request or response

Requirements

Installation

Install by adding the package as a Composer requirement:

Usage Examples

Basic Pipeline Registration (Mezzio)

ConfigProvider Registration

Configuration File

Development Overrides

Type Conversion

The middleware automatically converts values to the correct format for ini_set():

PHP Type Input Output
bool true 'On'
bool false 'Off'
int 256 '256'
string '256M' '256M'
null null ''

Common Configuration Options

Option Description Example
display_errors Show errors in output false (production)
error_reporting Error level bitmask E_ALL
memory_limit Maximum memory usage '256M'
max_execution_time Script timeout in seconds 30
upload_max_filesize Maximum upload file size '64M'
post_max_size Maximum POST data size '64M'
date.timezone Default timezone 'UTC'
session.cookie_secure HTTPS-only cookies true
session.cookie_httponly HTTP-only cookies true

Error Handling

If a configuration option cannot be set (due to PHP restrictions or invalid option names), the middleware throws an UnexpectedValueException:


All versions of ctw-middleware-phpconfig with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ctw/ctw-middleware Version ^5.0
psr/container Version ^1.0 || ^2.0
psr/http-message Version ^1.1 || ^2.0
psr/http-server-handler Version ^1.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 ctw/ctw-middleware-phpconfig contains the following files

Loading the files please wait ...