PHPackages                             gaetanroger/minimal-php-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. gaetanroger/minimal-php-framework

ActiveLibrary[Framework](/categories/framework)

gaetanroger/minimal-php-framework
=================================

Minimal PHP framework

1.1(8y ago)020MITPHPPHP &gt;=7.0

Since Jul 13Pushed 8y agoCompare

[ Source](https://github.com/GaetanRoger/minimal-php-framework)[ Packagist](https://packagist.org/packages/gaetanroger/minimal-php-framework)[ RSS](/packages/gaetanroger-minimal-php-framework/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (10)Used By (0)

Minimal PHP framwork
====================

[](#minimal-php-framwork)

[![Build Status](https://camo.githubusercontent.com/16d7e0a4c15699f5cdcfe84a446d11c70caa7355b79f4a83cc7b2d5f696c79a9/68747470733a2f2f7472617669732d63692e6f72672f47616574616e526f6765722f6d696e696d616c2d7068702d6672616d65776f726b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/GaetanRoger/minimal-php-framework)[![Coverage Status](https://camo.githubusercontent.com/c22bf87b070bcfc49215b2d9f92e267e8dc2a78795b4b497b7cc739829d27660/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f47616574616e526f6765722f6d696e696d616c2d7068702d6672616d65776f726b2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/GaetanRoger/minimal-php-framework?branch=master)

Concept
-------

[](#concept)

### General idea

[](#general-idea)

This minimal framework is meant to be used for a Model &amp; Manager PHP based application.

- Model: class that represents one key data object of your application
- Manager: singleton class managing all instances of one model

If your application is about cars, you could have the following classes and methods:

```
- Car
  - drive()
  - stop()
  - getDriver()
- CarManager
  - createNewCar()
  - getCarWithId(int)

```

### With the framework

[](#with-the-framework)

This minimal framework defines two classes for you: `AbstractModel` and `AbstractManager`. Both predefine methods that every model and manager need, like `Manager.find(int)`, `Manager.findAll()`, `Model.getId()`, `Model.insert()`, etc. (please find all defined methods in [Methods list](#methods-list) down below).

This framework makes data persistence easy by using properties and class names to match database table names. For example, if a model is named `AwesomeCar` the framework will look for a table named `awesome_car`.

How to install
--------------

[](#how-to-install)

This project is available as a [Composer dependency](https://packagist.org/packages/gaetanroger/minimal-php-framework). Please use the following command:

```
composer require gaetanroger/minimal-php-framework

```

How to use
----------

[](#how-to-use)

At the beginning of your application, please set the PDO connection in the model and manager like this:

```
AbstractModel::$database = $yourPDOConnection;
AbstractManager::$database = $yourPDOConnection;
```

This will allow the model to update and insert itself into the database, and the manager to find models (from an ID for example). Plus, all your models and manager will be able to easily access database.

Then simply make all your models and managers inherit from `Gaetanroger\MinimalPhpFramework\AbstractModel` and `Gaetanroger\MinimalPhpFramework\AbstractManager.` Be careful to follow naming conventions specified down below, as names are by default dynamically used by the framework.

Conventions to follow
---------------------

[](#conventions-to-follow)

##### Model

[](#model)

- A model class name **must** use CamelCase;
- A model class name **should not** end with `Model` (except if it is part of the actual model name);
- The model class name **must** be the exact conversion from snake\_case to CamelCase of the table name.

Valid model names with their table name:

```
FooBar --> foo_bar
Person --> person
AwesomeMechanicalPiece --> awesome_mechanical_piece

```

Invalid model names:

```
Foo_bar
person
AweSomeMechanicalPiece

```

##### Manager

[](#manager)

- A manager class name **must** use CamelCase;
- A manager class name **must** end with `Manager`;
- A manager class name **must** not contain `Manager` anywhere else;
- The manager class name **must** be identical with the model name plus the word `Manager`.

Valid manager names with their model name:

```
FooBarManager --> FooBar
PersonManager --> Person
AwesomeMechanicalPieceManager --> AwesomeMechanicalPiece

```

Invalid manager names:

```
FooBar
FooBarmanager
FooBar_Manager
FooManagerBarManager

```

Properties and methods list
-------------------------------------------------------------------

[](#properties-and-methods-list)

### AbstractModel

[](#abstractmodel)

- **$id**: ID of the model. The database field must be set to auto increment, as the framework uses this value to check if the model is already inserted into database or not.
- **insert()**: Create a now row in the table named after the model class by using the model properties as field names.
- **update()**: Same as `insert()` but updates the fields values of the row matching the model ID.
- **delete()**: Delete the table row matching the model ID.
- **getId()**: Returns model's ID.
- **getTableName()**: Returns the model table name by converting the class name to snake\_case. This method can be overridden if a custom table name must be used.

### AbstractManager

[](#abstractmanager)

- **find(id)**: Returns the model matching the ID from database. If no model matches, an exception is thrown.
- **findWhere(conditions)**: Returns the model filling the conditions. All the conditions are strict equality checks (`=` sign). If a different condition check is necessary, feel free to implement a new method.
- **findAll()**: Returns all models managed by this manager.
- **getTableName()**: Returns the model table name by converting the class name (without the word `Manager`) to snake\_case. This method can be overridden if a custom table name must be used.
- **getModelName(short)**: Returns the model name by trimming the word `Manager` from the class name. If `short` is false, will return full class name (package/model). This method can be overridden if a custom manager name must be used.
- **count(column, distinct)**: Counts rows in table using SQL `COUNT`. Default parameters will simply count all rows but you can specify what column you want to count and if you want it to only count distinct values.

Changelog
---------

[](#changelog)

Please take a look at [CHANGELOG.MD](CHANGELOG.MD)

Please criticize
----------------

[](#please-criticize)

Please feel free to contact me here or by [email](mailto:gaetanroger.fr@gmail.com) if something bothers you or does not work as expected.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity64

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

Recently: every ~30 days

Total

8

Last Release

3105d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/21ac8587f9fb4b0515685cbe62cdc7eca55d2ba834361e4376aee5f803505e0c?d=identicon)[GaetanRoger](/maintainers/GaetanRoger)

---

Top Contributors

[![GaetanRoger](https://avatars.githubusercontent.com/u/24687462?v=4)](https://github.com/GaetanRoger "GaetanRoger (115 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gaetanroger-minimal-php-framework/health.svg)

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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