PHPackages                             gcgov/framework - 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. [Framework](/categories/framework)
4. /
5. gcgov/framework

ActiveLibrary[Framework](/categories/framework)

gcgov/framework
===============

Open source framework for PHP applications. Includes MongoDB modelling system.

v6.0.9(1mo ago)2295MITPHPPHP &gt;=8.3

Since Jan 29Pushed 1mo ago2 watchersCompare

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

READMEChangelog (10)Dependencies (36)Versions (118)Used By (0)

gcgov/framework
===============

[](#gcgovframework)

A PHP framework for Garrett County Government, Maryland, USA applications.

The framework can be used to generate a full SSR app or as a rest API. It is primarily used internally to generate APIs. Using the available extensions, a full-fledged API with Microsoft Oauth authentication can be created with no custom code.

Getting Started
---------------

[](#getting-started)

The easiest way to start is to use the [framework scaffolding project](https://github.com/gcgov/framework-app-template)to start a new api and the [frontend app template](https://github.com/gcgov/framework-frontend-template) to start a corresponding front end application.

System Architecture
-------------------

[](#system-architecture)

### Application File System

[](#application-file-system)

All apps utilizing the framework for an entire lifecycle should use this file structure.

```
/api
├── app
│   ├── app.php
│   ├── constants.php
│   ├── renderer.php
│   ├── router.php
│   ├── cli
│   │   ├── index.php
│   │   ├── local.bat
│   │   ├── local-debug.bat
│   │   └── prod.bat
│   ├── config
│   │   ├── app.json
│   │   └── environment.json
│   ├── controllers
│   │   └── {controller.php}
│   └── models
│       └── {model.php}
└── www
    └── index.php

```

When you start with the [framework scaffolding project](https://github.com/gcgov/framework-app-template), you'll automatically start with some extra folders and tools.

```
/api
│...
├── www
│   │...
│   ├── web.config
│   ├── web-local.config
│   └── web-prod.config
├── app
│   │...
│   └── config
│       └── environment-local.json
│       └── environment-prod.json
├── scripts
│   ├── create-jwt-keys.ps1
│   └── setup.ps1
├── srv
│   ├── {env}
│   │   └── php.ini
│   ├── tmp
│   │   ├── files
│   │   ├── opcache
│   │   ├── sessions
│   │   ├── soaptmp
│   │   └── tmp
│   └── jwtCertificates
├── db
│   ├── backup
│   ├── restore-live-to-local.ps1
│   └── local-createuser.js
├── logs
└── update-production.ps1

```

### Core Files and Application Namespacing

[](#core-files-and-application-namespacing)

The webserver should point requests to /www/index.php. URL rewriting the original path to url parameter `R0` is required.

- [index.php](readme/index.php.md)

CLI requests should point to /app/cli/index.php.

- [app/cli/index.php](readme/cli-index.php.md)

The framework will register namespace `\app` to the `/app` directory and requires three core files in the root of `/app`:

- [app.php](readme/app.php.md)
- [renderer.php](readme/renderer.php.md)
- [router.php](readme/router.php.md)

### Components

[](#components)

#### Controllers

[](#controllers)

`\app\controllers`

A controller method called by the router must return one of the following supported types. It should always provide a response and never end code execution manually to ensure that the entire application lifecycle is executed.

New controller response types may be added to the framework to support new scenarios by adding the type and setting up rendering methods in `\gcgov\framework\renderer`

- \\gcgov\\framework\\models\\controllerDataResponse
- \\gcgov\\framework\\models\\controllerPagedDataResponse
- \\gcgov\\framework\\models\\controllerFileResponse
- \\gcgov\\framework\\models\\controllerFileBase64EncodedContentResponse
- \\gcgov\\framework\\models\\controllerViewResponse

#### Models

[](#models)

`\app\models`

#### Interfaces

[](#interfaces)

`\app\interfaces`

#### Exceptions

[](#exceptions)

`\app\exceptions`

#### Traits

[](#traits)

`\app\traits`

#### Services

[](#services)

`\app\services`

### Routing

[](#routing)

`\app\router` method `getRoutes()` must return an array of `\gcgov\framework\models\route` that maps the URL path to the controller and defines authentication requirements.

```
\gcgov\framework\models\route(
    string|array $httpMethod = '',
    string $route = '',
    string $class = '',
    string $method = '',
    bool $authentication = false,
    array $requiredRoles = [],
    bool $allowShortLivedUrlTokens=false
)
```

The following route will map incoming `GET` requests to `/structure` to controller `\app\controllers\structure`method `getAll`. The route requires authentication and the user must have the role `Structure.Read` to execute the request.

```
new route( 'GET', 'structure', '\app\controllers\structure', 'getAll', true, [ 'Structure.Read' ] );
```

When loading the app via CLI, the method will be `CLI` instead of a normal HTTP method. CLI routes do not support authentication.

```
new route( 'CLI', 'structure/cleanup', '\app\controllers\structure', 'cleanup', false );
```

Request Lifecycle
-----------------

[](#request-lifecycle)

1. `\www\index.php`
2. `\app\app::_before()`
3. `\app\app::__construct()`
4. `\app\router::_before()`
5. `\app\router::__construct()`
6. `\app\router::route()`
7. `\app\router::_after()`
8. `\app\renderer::_before()`
9. `\app\controllers\{route-controller}::_before()`
10. `\app\controllers\{route-controller}::__construct()`
11. `\app\controllers\{route-controller}::{route-method}()`
12. `\app\controllers\{route-controller}::_after()`
13. `\app\renderer::_after()`
14. `\app\app::_after()`

CLI
---

[](#cli)

Using the framework scaffolding project, you can run the app from CLI with `> app/cli/{env}.bat {url-path}` Ex: `> app/cli/local.bat /structure/cleanup`

To enable XDebug on the CLI execution, run `> app/cli/local-debug.bat {url-path}`Ex: `> app/cli/local-debug.bat /structure/cleanup`

Framework Services
------------------

[](#framework-services)

### Formatting

[](#formatting)

1. Sanitize file name: `\gcgov\framework\services\formatting::fileName( string $fileName, string $replacementForIllegalChars = '-', bool $forceLowerCase = true ): string`
2. Sanitize Excel tab name: `\gcgov\framework\services\formatting::xlsxTabName( string $tabName, string $replacementForIllegalChars = ' ', bool $forceLowerCase = false ) : string`
3. Format DateInterval to human readable string: `\gcgov\framework\services\formatting::getDateIntervalHumanText( \DateInterval $interval ) : string`

### GUID

[](#guid)

Create a GUID `\gcgov\framework\services\guid::create()`

### HTTP

[](#http)

Get status text for HTTP code `\gcgov\framework\services\http::statusText( int $code )`

### Logging

[](#logging)

`\gcgov\framework\services\log` will automatically create and append a log in /logs with a filename equal to the channel

- Debug `\gcgov\framework\services\log::debug( string $channel, string $message, array $context = [] )`
- Info `\gcgov\framework\services\log::info( string $channel, string $message, array $context = [] )`
- Notice `\gcgov\framework\services\log::notice( string $channel, string $message, array $context = [] )`
- Warning `\gcgov\framework\services\log::warning( string $channel, string $message, array $context = [] )`
- Error `\gcgov\framework\services\log::error( string $channel, string $message, array $context = [] )`
- Critical `\gcgov\framework\services\log::critical( string $channel, string $message, array $context = [] )`
- Alert `\gcgov\framework\services\log::alert( string $channel, string $message, array $context = [] )`
- Emergency `\gcgov\framework\services\log::emergency( string $channel, string $message, array $context = [] )`

### JWT Auth &amp; Certificates

[](#jwt-auth--certificates)

`\gcgov\framework\services\jwtAuth\jwtAuth()` provides all JWT authentication mechanisms. Explore the **Oauth Server Service** and **Microsoft Auth Token Exchange** extensions before rolling a new solution for authentication.

### Microsoft Services

[](#microsoft-services)

Deprecated - use  instead

### MongoDB

[](#mongodb)

Comprehensive database modeling system `\gcgov\framework\services\mongodb`

- [MongoDB Service](readme/mongodb.md)

### PDODB

[](#pdodb)

Initiate PDO connections using SQL connection details in app/config/environment.json. It is only a small wrapper around the native PDO class.

Read user connection: `new gcgov\framework\services\pdodb\pdodb(true, $databaseName)`

Write user connection: `new gcgov\framework\services\pdodb\pdodb(false, $databaseName)`

Extensions
----------

[](#extensions)

Extensions add service or app level functionality to the app that registers them. Extensions may expose new endpoints.

- **Open API Documentation** `gcgov/framework-service-documentation`
    -
    - Add namespace `\gcgov\framework\services\documentation` to `\app\app->registerFrameworkServiceNamespaces()`
- **Microsoft Auth Token Exchange** `gcgov/framework-service-auth-ms`
    -
    - Add namespace `\gcgov\framework\services\authmsfront` to `\app\app->registerFrameworkServiceNamespaces()`
- **Oauth Server Service** `gcgov/framework-service-auth-oauth-server`
    -
    - Add namespace `\gcgov\framework\services\authoauth` to `\app\app->registerFrameworkServiceNamespaces()`
- **User CRUD** `gcgov/framework-service-user-crud`
    -
    - Add namespace `\gcgov\framework\services\usercrud` to `\app\app->registerFrameworkServiceNamespaces()`
- **Cron Monitor** `gcgov/framework-service-gcgov-cron-monitor`
    -
    - Add namespace `gcgov\framework\services\cronMonitor` to `\app\app->registerFrameworkServiceNamespaces()`

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance90

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 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 ~17 days

Recently: every ~36 days

Total

112

Last Release

48d ago

Major Versions

v1.14.1 → v2.0.02023-08-07

v2.4.2 → v3.0.02024-03-07

v3.1.5 → v4.0.02024-09-05

v4.3.5 → v5.0.02025-07-31

v5.0.1 → v6.0.0-rc.12025-08-25

PHP version history (5 changes)v1.1.1PHP &gt;=7.4

v1.2.0PHP &gt;=8.0

v1.14.1PHP &gt;=8.1

v4.2.0PHP &gt;=8.2

v5.0.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/e97ad9c5583ee03e1f670eba13bd11b81e3374da1941dce10f6da80e5dc6d8eb?d=identicon)[andrewsauder](/maintainers/andrewsauder)

---

Top Contributors

[![andrewsauder](https://avatars.githubusercontent.com/u/1380472?v=4)](https://github.com/andrewsauder "andrewsauder (269 commits)")

---

Tags

php

### Embed Badge

![Health badge](/badges/gcgov-framework/health.svg)

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

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)

PHPackages © 2026

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