PHP Classes

PHP Common Class Library: Set of classes that provides common functionality

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-07-28 (-5 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: 121 All time: 9,494 This week: 46Up
Version License PHP version Categories
common 2.14.1The PHP License7Localization, Databases, Text processing, L..., C..., P...
Description 

Author

The common classes package provides some of the classes used by CIDRAM, phpMussel, etc., as a separate packages.

The common classes package currently contains the following classes:

- Cache: A simple, unified cache handler. Currently, it supports APCu, Memcached, Redis, PDO, and flat file caching.

- CommonAbstract: Common abstract for the package.

- ComplexStringHandler: Provides an easy way to iterate over the parts of a given string, identified by a given pattern, in order to execute a given closure to those parts of the given string, or to the glue that separates those parts.

- Context: Context attribute class (used internally by a few classes in the package).

- DelayedIO: Provides an easy, simple solution for when needing to read and update a number of files, but delay rewriting the files for a while.

- Demojibakefier: Intended to normalize the character encoding of a given string to a preferred character encoding when the given string's byte sequences don't match the expectations of the preferred character encoding. Useful in cases where a block of data might conceivably be composed of several different unspecified, unknown encodings.

- Events: Allows the orchestration of "events" throughout a codebase by providing some simple methods to assign handlers to a particular event and to subsequently invoke those handlers at a later point in the codebase where the "event" is to occur.

- IPHeader: Attempts to resolve an originating IP address from a preferred source, or REMOTE_ADDR if the preferred source isn't available.

- L10N: Used by projects to handle L10N data, the L10N handler reads in an array of L10N strings and provides some safe and simple methods for manipulating and returning those strings when needed, and for handling cardinal plurals, where integers and fractions are concerned alike, based upon the pluralization rules specified by the L10N from a range of various pluralization rules available, to be able to suit the needs of most known languages.

- Matrix: Facilitates the generation of multidimensional arrays to an arbitrarily specified depth and number of elements, and facilitates iteration through those multidimensional arrays in any direction (whether up and down a particular array, across different depths, etc.) via arbitrary callable functions and closures.

- NumberFormatter: Can format numbers into various different kinds of numeral systems, or remove the format from an already formatted number.

The class provides a more controllable, customizable mechanism for number formatting than PHP's internal number_format() function.

Operation: Used by projects for various operations related to dependency management (an integral part of the internal updates system for some packages).

Request: Used by projects to send outbound requests through cURL.

YAML: Used by projects to handle YAML data (e.g., reading data from a YAML file, reconstructing PHP variables back into YAML data, etc.)

Picture of Caleb
Name: Caleb <contact>
Classes: 4 packages by
Country: Australia Australia
Age: ???
All time rank: 345241 in Australia Australia
Week rank: 195 Up1 in Australia Australia Up
Innovation award
Innovation award
Nominee: 2x

Recommendations

Detect file encoding and convert it to UTF-8 without BOM
I am unable to detect file encoding, that needs to be converted

Instructions

All classes in the common classes package use the namespace Maikuolan\Common.

Documentation

v1: PHP >= 5.4 < 8.4 v2: PHP >= 7.2 License: GPL v2

Common Classes Package.

The common classes package is intended to provide some of the classes that I originally wrote for common use by CIDRAM, phpMussel, etc as a separate, redistributable package, available to be readily integrated and used with other projects and packages via Composer.

All classes in the common classes package use the namespace Maikuolan\Common.

The common classes package currently contains the following classes: - Cache: A simple, unified cache handler used by the CIDRAM and phpMussel projects for their caching needs. Currently, it supports APCu, Memcached, Redis, PDO, and flatfile caching. - CommonAbstract: Common abstract for the common classes package. Not to be instantiated directly; To be extended by the other classes. - ComplexStringHandler: The complex string handler class provides an easy way to iterate over the parts of a given string, identified by a given pattern, in order to execute a given closure to those parts of the given string, or to the glue that separates those parts. - Context: Context attribute class (used internally by a few classes in the package). Not to be instantiated directly. - DelayedIO: Provides an easy, simple solution for when needing to read and update a number of files, but delay rewriting the files for a while. - Demojibakefier: Intended to normalise the character encoding of a given string to a preferred character encoding when the given string's byte sequences don't match the expectations of the preferred character encoding. Useful in cases where a block of data might conceivably be composed of several different unspecified, unknown encodings. - Events: Allows the orchestration of "events" throughout a codebase by providing some simple methods to assign handlers to a particular event and to subsequently invoke those handlers at a later point in the codebase where the "event" is to occur. - IPHeader: Attempts to resolve an originating IP address from a preferred source, or REMOTE_ADDR if the preferred source isn't available. - L10N: Used by the CIDRAM and phpMussel projects to handle L10N data, the L10N handler reads in an array of L10N strings and provides some safe and simple methods for manipulating and returning those strings when needed, and for handling cardinal plurals, where integers and fractions are concerned alike, based upon the pluralisation rules specified by the L10N from a range of various pluralisation rules available, to be able to suit the needs of most known languages. - Matrix: Facilitates the generation of multidimensional arrays to an arbitrarily specified depth and number of elements, and facilitates iteration through those multidimensional arrays in any direction (whether up and down a particular array, across different depths, etc) via arbitrary callables and closures. - NumberFormatter: Used by the CIDRAM and phpMussel projects to format numbers generated by their front-end pages, the class provides a more controllable, customisable mechanism for number formatting than PHP's internal number_format() function. - Operation: Used by the CIDRAM and phpMussel projects for various operations related to dependency management (an integral part of the internal updates system). - Request: Used by the CIDRAM and phpMussel projects to send outbound requests through cURL. - YAML: Used by the CIDRAM and phpMussel projects to handle YAML data.

How to install:

The recommended way to install it is by using Composer:

composer require maikuolan/common

You can, however, download the classes you need from this repository manually, if you want to do so.

After you've downloaded the package, or any needed classes, PSR-4 autoloading is preferred way to access the classes (particularly if you're using a large number of different, unrelated classes). If you're installing the package via Composer, all you have to do is require_once 'vendor/autoload.php'; and everything will be taken care of. Alternatively, if you're installing the package or its classes manually (or without Composer), or if you don't want to use a PSR-4 autoloader, you can simply require or include any needed classes into your projects by using an include or require statement in your code, to point to the needed classes in any PHP code that needs them.

Other information:

Licensing:

Provided using the GNU General Public License version 2.0 (GPLv2).

For support:

Please use the issues page of this repository.

For contributors:

[\[CONTRIBUTING.md\] Want to help?](https://github.com/Maikuolan/Common/blob/v2/CONTRIBUTING.md)

Last Updated: 2 July 2025 (2025.07.02).


  Files folder image Files (52)  
File Role Description
Files folder image.github (1 file, 1 directory)
Files folder image.tests (11 files, 1 directory)
Files folder imagesrc (13 files)
Files folder image_docs (13 files)
Accessible without login Plain text file Changelog.txt Doc. Documentation
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file CONTRIBUTING.md Data Auxiliary data
Accessible without login Plain text file LICENSE.txt Doc. Documentation
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file SECURITY.md Data Auxiliary data
Accessible without login Plain text file tests.php Test Unit test script

  Files folder image Files (52)  /  .github  
File Role Description
Files folder imageworkflows (2 files)
  Accessible without login Plain text file FUNDING.yml Data Auxiliary data

  Files folder image Files (52)  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file php-cs-fixer.yml Data Auxiliary data
  Accessible without login Plain text file v2.yml Data Auxiliary data

  Files folder image Files (52)  /  .tests  
File Role Description
Files folder imagefixtures (5 files)
  Accessible without login Plain text file ComplexStringHandlerTest.php Test Unit test script
  Accessible without login Plain text file DelayedIOTest.php Test Unit test script
  Accessible without login Plain text file DemojibakefierTest.php Test Unit test script
  Accessible without login Plain text file EventsTest.php Test Unit test script
  Accessible without login Plain text file IPHeaderTest.php Test Unit test script
  Accessible without login Plain text file L10NTest.php Test Unit test script
  Accessible without login Plain text file MatrixTest.php Test Unit test script
  Accessible without login Plain text file NumberFormatterTest.php Test Unit test script
  Accessible without login Plain text file OperationTest.php Test Unit test script
  Accessible without login Plain text file RequestTest.php Test Unit test script
  Accessible without login Plain text file YAMLTest.php Test Unit test script

  Files folder image Files (52)  /  .tests  /  fixtures  
File Role Description
  Accessible without login Plain text file iotest.txt Data Auxiliary data
  Accessible without login Plain text file reconstruct.yaml Data Auxiliary data
  Accessible without login Plain text file syntax.yaml Data Auxiliary data
  Accessible without login Plain text file utf16be.yaml Data Auxiliary data
  Accessible without login Plain text file utf16le.yaml Data Auxiliary data

  Files folder image Files (52)  /  src  
File Role Description
  Plain text file Cache.php Class Class source
  Plain text file CommonAbstract.php Class Class source
  Plain text file ComplexStringHandler.php Class Class source
  Plain text file Context.php Class Class source
  Plain text file DelayedIO.php Class Class source
  Plain text file Demojibakefier.php Class Class source
  Plain text file Events.php Class Class source
  Plain text file IPHeader.php Class Class source
  Plain text file L10N.php Class Class source
  Plain text file Matrix.php Class Class source
  Plain text file NumberFormatter.php Class Class source
  Plain text file Operation.php Class Class source
  Plain text file YAML.php Class Class source

  Files folder image Files (52)  /  _docs  
File Role Description
  Accessible without login Plain text file Cache.md Data Auxiliary data
  Accessible without login Plain text file CommonAbstract.md Doc. Documentation
  Accessible without login Plain text file ComplexStringHandler.md Example Example script
  Accessible without login Plain text file DelayedIO.md Data Auxiliary data
  Accessible without login Plain text file Demojibakefier.md Example Example script
  Accessible without login Plain text file Events.md Doc. Documentation
  Accessible without login Plain text file IPHeader.md Doc. Documentation
  Plain text file L10N.md Class Class source
  Accessible without login Plain text file Matrix.md Doc. Documentation
  Accessible without login Plain text file NumberFormatter.md Example Example script
  Accessible without login Plain text file Operation.md Doc. Documentation
  Accessible without login Plain text file Request.md Doc. Documentation
  Accessible without login Plain text file YAML.md Example Example script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:121
This week:0
All time:9,494
This week:46Up