PHPackages                             3bg-supply-co/php-functions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. 3bg-supply-co/php-functions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

3bg-supply-co/php-functions
===========================

This package contains random functions and classes that can be reused in any PHP project.

1.6.3(3y ago)096MITPHPPHP ^8.0

Since May 28Pushed 3y agoCompare

[ Source](https://github.com/3bg-supply-co/php-functions)[ Packagist](https://packagist.org/packages/3bg-supply-co/php-functions)[ RSS](/packages/3bg-supply-co-php-functions/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (4)DependenciesVersions (20)Used By (0)

PHP Functions
=============

[](#php-functions)

This package is a collection of reusable classes and functions that are currently being used in many of our projects.

Table of Contents
-----------------

[](#table-of-contents)

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Usage](#usage)
    - [ApiResponse Class](#api-response-class)
    - [HttpPost Class](#http-post-class)
    - [GenericFunctions](#generic-functions)

Requirements
------------

[](#requirements)

In order to use this package, the following requirements must be met:

- **credentials.ini** file must exist *2 levels* above the root directory
    - For example: if the code is deployed to the following directory: `/var/www/html/test/`, then the file would have to be located in the following directory: `/var/www/credentials/credentials.ini`.
- [Composer](https://getcomposer.org/)
- PHP version **7.0+**
- [SSH Access](https://github.com/settings/keys)
    - Follow this [tutorial](https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) to set up the SSH Key
    - You can test it by running the following command on the machine with the SSH Key: `ssh -T git@github.com`

Installation
------------

[](#installation)

To install this package, the following steps must be followed (in order):

- Create a **composer.json** file in your project by running the following command: `composer init`
- After going through the options, add the following code to the **composer.json** file:

```
    "minimum-stability": "dev",
    "require": {
      "3bg-supply-co/php-functions": "^1.6"
    }
```

- Run `composer update -n`

Usage
-----

[](#usage)

To use this collection of code, determine what your need is. All classes found in this package will use the base *namespace* **Common3BG**.

To use the logging function ***writeLog()***, the */tmp/* directory must have *write* permissions by the user executing the script.

For example, if all you need is access to the functions found in the `src/GenericFunctions.php` file, then just call said function in your script.

If you need to use one of the classes (such as **ApiResponse**), then you must include the proper *namespace*. For example, the following line of code is needed to use the **ApiResponse** class:

```
  use Common3BG\ApiResponse as ApiResponse;
```

### ApiResponse Class

[](#apiresponse-class)

This class takes no parameters.

The following method

**Sample PHP Code**```
require (__DIR__) . '/vendor/autoload.php';
use Common3BG\ApiResponse as ApiResponse;

$apiResponse = new ApiResponse();

// Sample #1: simple one liner being added to message then returning the response
$apiResponse->addMessage('Testing a custom message');
$apiResponse->sendResponse();

// Sample #2: adding another message then returning the response
$apiResponse->addMessage('Testing a second custom message');
$apiResponse->sendResponse();

// Sample #3: sending a fail response without any parameters
$apiResponse->sendFailResponse();

// Sample #4: adding a string error message with no data, then returning the fail response
$apiResponse->sendFailResponse('Custom Error Message with no $data given');

// Sample $5: adding an error message with data to the errors, then returning the fail response
$apiResponse->sendFailResponse(['message' => 'Original error message from $data', 'test' => 'Some error sample here (test key is not needed)']);
$apiResponse->sendFailResponse();

// Sample #6: adding multiple errors to the errors, then returning the fail response
$apiResponse->addError(['message' => 'Custom Error Message #2', 'test' => 'Sample Error #2']);
$apiResponse->addError(['message' => 'Custom Error Message #3', 'test' => 'Sample Error #3']);
$apiResponse->sendFailResponse();
```

 **Sample Success Response**```
{
    "success": true,
    "message": "",
    "data": [
        "Testing a success message",
        {
            "sample": "Success #1 Message"
        }
    ],
    "errors": []
}
```

 **Sample Failure Response**```
{
    "success": false,
    "message": "",
    "data": [],
    "errors": [
        {
            "message": "Custom Error Message #1",
            "test": "Sample Error #1"
        },
        {
            "message": "Custom Error Message #2",
            "test": "Sample Error #2"
        },
        {
            "message": "Custom Error Message #3",
            "test": "Sample Error #3"
        },
        {
            "message": "Error Message.",
            "test": "Testing an object being added to the errors"
        }
    ]
}
```

### HttpPost Class

[](#httppost-class)

Documentation Coming Soon!

### GenericFunctions

[](#genericfunctions)

Documentation Coming Soon!

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~49 days

Recently: every ~208 days

Total

18

Last Release

1332d ago

Major Versions

0.1.6 → 1.02020-05-28

PHP version history (3 changes)0.1PHP ^7.2

1.1PHP ^7.0

1.6.3PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22687988?v=4)[ben3bg](/maintainers/ben3bg)[@ben3bg](https://github.com/ben3bg)

---

Top Contributors

[![ben3bg](https://avatars.githubusercontent.com/u/22687988?v=4)](https://github.com/ben3bg "ben3bg (53 commits)")

### Embed Badge

![Health badge](/badges/3bg-supply-co-php-functions/health.svg)

```
[![Health](https://phpackages.com/badges/3bg-supply-co-php-functions/health.svg)](https://phpackages.com/packages/3bg-supply-co-php-functions)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k187.2M2.6k](/packages/composer-composer)[symfony/event-dispatcher

Provides tools that allow your application components to communicate with each other by dispatching events and listening to them

8.6k985.9M3.4k](/packages/symfony-event-dispatcher)[symfony/polyfill-php80

Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions

1.7k815.2M455](/packages/symfony-polyfill-php80)[symfony/var-exporter

Provides tools to export, instantiate, hydrate, clone and lazy-load PHP objects

2.1k378.1M437](/packages/symfony-var-exporter)[seld/phar-utils

PHAR file format utilities, for when PHP phars you up

875180.0M32](/packages/seld-phar-utils)[dansmith/laravel5-foundation

Zurb Foundation components for Laravel5

104.6k](/packages/dansmith-laravel5-foundation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
