PHPackages                             xcalegroup/baselib - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. xcalegroup/baselib

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

xcalegroup/baselib
==================

Baselib for the mundane issues

v1.0(4y ago)021MITPHPPHP &gt;=7.0

Since Aug 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/xcalegroup/baselib)[ Packagist](https://packagist.org/packages/xcalegroup/baselib)[ Docs](https://xcale.net)[ RSS](/packages/xcalegroup-baselib/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Baselib
=======

[](#baselib)

A library for handling the most mundane things like exception handling and logging aswell as the most often needed functions

```
composer require xcalegroup/baselib

```

Requirements
============

[](#requirements)

You need to define the following contants in a file named baselibconstants.php placed in the root folder of your project. The Baselib will include the file like this

```
require_once(__DIR__ . "/baselibconstants.php");

```

**Baselib requirements for logging**

```
define("__BASELIB__NAME", "Application name");
define("__BASELIB__DEBUG", true);
define("__BASELIB__LOGGING", true);
define("__BASELIB__TRACE", true);
define("__BASELIB__REMOTE__DATA", true);
define("__BASELIB__REMOTE__ENDPOINT", "Enpoint URL for your remote logging, if enabled");
define("__BASELIB__REMOTE__KEY", "Key for remote logging, if you choose to implement it");

```

**Baselib requirements for handling database**

This could be defined in another constants.php file, but is rquired to auto create tables if missing as well as adding data to the database

```
define("__BASELIB__DB_TYPE", "mysql");
define("__BASELIB__DB_HOST", "localhost");
define("__BASELIB__DB_USER", "USER");
define("__BASELIB__DB_PASS", "PASS");
define("__BASELIB__DB_NAME", "NAME");
define("__BASELIB__CREATE_DB", false); // if true it will create the tables needed, but only if the table does not exists.

```

If you allready have your database defined then use those defined constants in your baselibconstants file like this

```
require_once(__DIR__ . "[YOUR DEFINES FILE]");

define("__BASELIB__DB_TYPE", DB_TYPE);
define("__BASELIB__DB_HOST", DB_HOST);
define("__BASELIB__DB_USER", DB_USER);
define("__BASELIB__DB_PASS", DB_PASS);
define("__BASELIB__DB_NAME", DB_NAME);
define("__BASELIB__CREATE_DB", false);

```

Usage
=====

[](#usage)

```
class YouClass extends BaselibClass
{
    public function Method1()
    {
        $this->trace->add(__FUNCTION__);
        ...
    }

    public function Method2()
    {
        $this->trace->add(__FUNCTION__);
        try{
            ...
        }
        catch(Exception $e){
            $this->log(Severity::ERROR,$e);
        }
        finally{

        }
    }
}

```

The baselibClass provides numerous ways of logging

**collections**

Collections are stored upon object destruction. Either by using unset or by letting PHP handle carbage collection.

- trace
- logs

**methods**

Methods log instantly on each call

- log
- message

**Remote Endpoint**

The remote endpoint will be called using POST. Handle variables like the below, where key is used as a security measure. Use it as part of an API validation process. Using remote logging might be usefull for small projects or if you have multiple CRON jobs and wish to have logging easy at hand.

```
$_POST['key']!='') {
    $key=$_POST['key'];
    $app=$_POST['app'];
    $severity=$_POST['severity'];
    $errorcode=$_POST['errorcode'];
    $error=$_POST['error'];
    $stack_trace=$_POST['stack_trace'];
    $user=$_POST['user'];
}

```

**FileReader class - For reading Huge file**

This class has been tested on files containing more than 2.5 million lines and sizes above 72GB data. Its does not put pressure on your server and can run multiple instances on different files

```
$filereader = new FileReader('file.extension', true);
$filereader->read('handleLineContent');

function handleLineContent($content){
    //Handle the content read. This is called each time a line is read
}

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1731d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/238412f973f1d30ed620f3b6662dc7584b8632de50a5c0e5ba781bf3b349e06f?d=identicon)[xcalegroup](/maintainers/xcalegroup)

---

Top Contributors

[![sitepointsystems](https://avatars.githubusercontent.com/u/89264878?v=4)](https://github.com/sitepointsystems "sitepointsystems (43 commits)")

---

Tags

loggingexception handlingremote-loggingbaseclass

### Embed Badge

![Health badge](/badges/xcalegroup-baselib/health.svg)

```
[![Health](https://phpackages.com/badges/xcalegroup-baselib/health.svg)](https://phpackages.com/packages/xcalegroup-baselib)
```

###  Alternatives

[monolog/monolog

Sends your logs to files, sockets, inboxes, databases and various web services

21.4k964.9M7.0k](/packages/monolog-monolog)[symfony/monolog-bundle

Symfony MonologBundle

2.9k249.1M1.6k](/packages/symfony-monolog-bundle)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.3k114.3M154](/packages/sentry-sentry-laravel)[sentry/sentry-symfony

Symfony integration for Sentry (http://getsentry.com)

73761.4M66](/packages/sentry-sentry-symfony)

PHPackages © 2026

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