Download the PHP package greatcode/controller-global without Composer

On this page you can find all versions of the php package greatcode/controller-global. 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 controller-global

controller-global

Base Library Controller Global for GC — a PHP utility library providing a PDO wrapper, generic DML/SELECT helpers, AES-256-CBC encoding, and a POS-group integrator client.

Requirements: PHP >= 8.2, ext-pdo, ext-pdo_sqlite, ext-openssl, ext-curl, guzzlehttp/guzzle ^7.10

Installation


CtrlGlobal

General-purpose controller with DML helpers, SELECT wrappers, HTTP client wrappers, and AES-256-CBC encode/decode. Resolves its Connection automatically.

Instantiation

When constructed with null (default), it checks for a global $cfg['db'] array first, then falls back to Connection::fromEnv().

The encryption key is resolved in this order:

  1. Explicit $encryption_key constructor argument
  2. ENCRYPTION_KEY environment variable
  3. Fallback value 'secret'

DML

insert()

insertAll()

Insert multiple rows in a single statement.

update()

delete()

deleteAll()

Delete multiple rows, each matched by its own condition set (conditions within a row are AND-joined; rows are OR-joined).

SELECT

GetGlobalFilter()

Execute a SELECT and return all rows as associative arrays. Supports both positional (?) and named (:key) bindings.

runSql()

Same behaviour as GetGlobalFilter — execute SQL and return all rows.

getName()

Return the name column of the first result row, or an empty string if no rows match.

Encoding

AES-256-CBC encode/decode. The key is determined by the constructor (see Instantiation above).

Two instances using different keys will produce different ciphertext for the same input and cannot decode each other's output.

HTTP client

Thin wrappers around a shared GuzzleHttp\Client singleton. All methods return a PSR-7 ResponseInterface.

The underlying GuzzleHttp\Client instance is a static singleton shared across all CtrlGlobal instances:


Connection

Connection extends PDO with safe defaults and convenience factory methods.

Default PDO attributes set on every connection:

Attribute Value
ATTR_ERRMODE ERRMODE_EXCEPTION
ATTR_DEFAULT_FETCH_MODE FETCH_ASSOC
ATTR_EMULATE_PREPARES false
ATTR_PERSISTENT false

Direct constructor

Override any default attribute:

fromConfig()

Build a connection from an associative array. Supported drivers: mysql, pgsql, sqlite.

fromEnv()

Reads connection parameters from environment variables.

Env var Default
DB_DRIVER mysql
DB_HOST 127.0.0.1
DB_PORT 3306
DB_NAME (empty)
DB_CHARSET utf8mb4
DB_USER (empty)
DB_PASSWORD (empty)

getInstance() — singleton

Returns the same Connection instance across calls. Useful for sharing a single connection throughout a request lifecycle.

transaction()

Wraps a callable in a database transaction. Commits on success, rolls back and re-throws on any exception.


CtrlGroupPos

HTTP client for a remote POS-group integrator service.

Methods

Method Description
getGroupPos(array $params) Query POS user data. Required keys: group_pos, browser, waktu.
updateLoginProcess($id, $status) Update the login status of a POS session.
updateLastDate($id, $last_data) Update the last-data timestamp for a POS entry.
updatePOSLastDate(array $datas) Bulk-update POS last dates via JSON POST. Each item needs status and data.
updatePosToken($token, $id, $status) Update the token associated with a POS session.
updateBranchId($branchID, $id) Update the branch ID for a POS entry.
saveToLocal($table, $arFieldValues) Insert rows into a local table via CtrlGlobal::insertAll(). Returns bool.

Logger

Logger is a facade for Monolog. It is initialized in CtrlGlobal::initialize().

Method Description
Log::initialize($name, $config) Initialize the logger. See Logger::__construct() for $config details.
Log::getInstance() Get the logger instance.
Log::debug($message) Log debug.
Log::info($message) Log info.
Log::warning($message) Log warning.
Log::error($message) Log error.
Log::fatal($message) Log fatal.

Running tests

The test suite is split into two suites: Unit (SQLite, no external services) and Integration (real MySQL).

Unit tests

Integration tests (MySQL)

Requires ext-pdo_mysql. Set DB_NAME at minimum; all 23 tests skip automatically when it is absent.

Integration tests (PostgreSQL)

Requires ext-pdo_pgsql. Set PGSQL_NAME at minimum; all 23 tests skip automatically when it is absent.

Run all suites

CI

GitHub Actions runs three jobs in parallel:

Job Matrix Services
unit PHP 8.2 / 8.3 / 8.4 —
integration PHP 8.2 / 8.3 / 8.4 × MySQL 8.0 / 8.4 MySQL service container
integration-pgsql PHP 8.2 / 8.3 / 8.4 × PostgreSQL 15 / 17 PostgreSQL service container

Coverage (Xdebug) is collected on the Unit job for PHP 8.3 and uploaded as a workflow artifact.


All versions of controller-global with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-pdo Version *
ext-pdo_sqlite Version *
ext-openssl Version *
ext-curl Version *
guzzlehttp/guzzle Version ^7.10
monolog/monolog Version ^3.10
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 greatcode/controller-global contains the following files

Loading the files please wait ...