PHPackages                             stilmark/base - 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. stilmark/base

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

stilmark/base
=============

Shared core functions for web apps

1.7.4(7mo ago)037[6 issues](https://github.com/Stilmark/Base/issues)1MITPHPPHP ^8.2

Since Sep 5Pushed 7mo agoCompare

[ Source](https://github.com/Stilmark/Base)[ Packagist](https://packagist.org/packages/stilmark/base)[ RSS](/packages/stilmark-base/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (22)Used By (1)

Stilmark Base
=============

[](#stilmark-base)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/12ba79b4c8771d8067d75af9042c66480c860df180785c6462538e847ea1a5d2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e322d626c75652e737667)](https://php.net)[![Composer](https://camo.githubusercontent.com/95a77a49639665923ca90012f10d743d39059975867c9351111c739c2b0fa3c2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6d706f7365722d5053522d2d342d6f72616e67652e737667)](https://getcomposer.org)[![CodeFactor](https://camo.githubusercontent.com/53aae4571352b69453149256f6bb9bea81546a9ed228f42982287776d0e5c003/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f7374696c6d61726b2f626173652f6261646765)](https://www.codefactor.io/repository/github/stilmark/base)

A lightweight PHP utility library providing essential functionality for modern web applications. Base serves as a foundation for building PHP applications with clean, reusable components.

Features
--------

[](#features)

- **Environment Management**: Load and access `.env` variables.
- **Request Handling**: A unified interface for HTTP requests, including input retrieval, validation, and sanitization.
- **Routing**: A simple and fast router with middleware support.
- **Controllers**: A base controller to extend for application logic.
- **Response Rendering**: Helpers for sending JSON and CSV responses.
- **Session Management**: Secure session handling with timeout management and flash data support.
- **CSRF Protection**: Time-bucketed CSRF tokens with automatic rotation and origin validation.
- **Authentication**: Multi-provider OAuth2 support (e.g., Google) with session regeneration and timeout management.
- **JWT Support**: JSON Web Token generation and validation with configurable claims and expiration.
- **Logging**: PSR-3 compliant logging with built-in Rollbar integration.
- **Helper Utilities**: Static methods for common tasks like string manipulation.

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

[](#requirements)

- **PHP**: version 8.2 or higher
- **Composer** for dependency management

### Dependencies

[](#dependencies)

Base relies on the following libraries (installed via Composer):

- [symfony/dotenv](https://github.com/symfony/dotenv) – for loading environment variables from `.env` files
- [nikic/fast-route](https://github.com/nikic/FastRoute) – for routing
- [league/oauth2-client](https://github.com/thephpleague/oauth2-client) – for OAuth2 authentication
- [league/oauth2-google](https://github.com/thephpleague/oauth2-google) – Google OAuth2 provider
- [firebase/php-jwt](https://github.com/firebase/php-jwt) – for JWT token generation and validation
- [rollbar/rollbar](https://github.com/rollbar/rollbar-php) – for error tracking and monitoring

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

[](#installation)

Install via Composer:

```
composer require stilmark/base
```

Quick Start
-----------

[](#quick-start)

### 1. Basic Setup

[](#1-basic-setup)

Create a bootstrap file (`index.php`):

```
