PHPackages                             gp/sys - 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. gp/sys

ActiveLibrary[Framework](/categories/framework)

gp/sys
======

A simple PHP MVC framework with ORM, autoload, DI, Validator, etc support for simple application

0.0.4(10mo ago)09MITPHPPHP ^8.1CI passing

Since Mar 23Pushed 10mo agoCompare

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

READMEChangelog (5)Dependencies (10)Versions (12)Used By (0)

GP SYS Framework
================

[](#gp-sys-framework)

GP SYS is HMVC based PHP Framework that simplifies your work in developing the web application.

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

[](#table-of-contents)

[Requirements](#requirements)

- [Installation](#installation)
- [Directory Structure](#directory-structure)
- [Getting Started](#getting-started)
- [Features](#features)
- [Classes](#classes)
    - [DBQuery](#dbquery)
    - [Database](#database)
    - [Model](#model)
    - [Events](#events)
- [Usage](#usage)
    - [Frame Queries](#frame-queries)
        - [Select Query](#select-query)
        - [Insert Query](#insert-query)
        - [Update Query](#update-query)
        - [Delete Query](#delete-query)
    - [Running Queries](#running-queries)
    - [Transaction Management](#transaction-management)
    - [Creating a Custom DB Driver](#creating-a-custom-db-driver)
    - [Creating an ORM Model](#creating-an-orm-model)
    - [Performing CRUD Operations with ORM Model](#performing-crud-operations-with-orm-model)
    - [Handling Relationships](#handling-relationships)
    - [Events](#events)
    - [Creating and Loading ORM Models with Relations](#creating-and-loading-orm-models-with-relations)
- [Example](#example)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)
- [Author](#author)

---

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

[](#requirements)

- PHP 8.1 or higher
- Composer (optional but recommended for autoloading).

---

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

[](#installation)

- **Clone the template:**```
    git clone https://github.com/periyandavar/gp_sys_template.git
    cd gp_sys_template
    ```
- **Install dependencies**:

```
composer install

```

- **Init the application**:

```
php vendor\bin\run init -e=dev -s=1

#-e - environment
#-s - supress system errors.

```

- **Configure your environment**:

    Copy and edit the appropriate config files in config/ for your environment (dev, prod, etc). Copy the env file contents to .env file.
- **Set up your web server**:

    Point your document root to the public/ directory.

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

[](#getting-started)

- Configure your web server to point to the public/ directory.
- Set up your environment variables (if needed) in a .env file.
- Start building your modules inside the src/ directory.

Features
--------

[](#features)

- **HMVC Architecture**: Organize your code into modules for better maintainability.
- **Core Utilities**: Includes helpers for reflection, testing, and property/method access.
- **Testing Support**: Base TestCase class with helpers for invoking private/protected methods and properties.
- **Composer Autoloading**: PSR-4 autoloading for easy class management.
- **PHPStan Integration**: Static analysis ready with a sample phpstan.neon configuration.

Directory Structure
-------------------

[](#directory-structure)

Your project should follow a modular structure similar to:

```
project-root/
├── config/
│   ├── constants.php
│   ├── dev/
│   │   ├── config.php
│   │   └── db.php
│   ├── local/
│   │   ├── config.php
│   │   └── db.php
│   ├── prod/
│   │   ├── config.php
│   │   └── db.php
│   └── test/
│       ├── config.php
│       └── db.php
├── console/
│   ├── commands.php
│   ├── config.php
│   └── Welcome.php
├── migrations/
│   ├── Migration_YYYYMMDD_HHMMSS_Description.php
│   └── ...
├── src/
│   ├── DataModel/
│   │   └── App.php
│   ├── Filters/
│   │   └── AppFilter.php
│   ├── Module/
│   │   ├── App/
│   │   │   ├── Controller/
│   │   │   │   └── AppController.php
│   │   │   ├── Module.php
│   │   │   ├── routes.php
│   │   │   └── View/
│   │   │       └── AppView.php
│   │   └── Crud/
│   │       ├── Controller/
│   │       │   └── CrudController.php
│   │       ├── Module.php
│   │       ├── routes.php
│   │       ├── autoloads.php
│   │       └── services.php
│   ├── Service/
│   │   └── AppService.php
│   └── View/
│       └── login.php
├── tests/
│   └── ExampleTest.php
├── vendor/
├── public/
│   └── index.php
├── composer.json
└── README.md

```

---

Usage Example
-------------

[](#usage-example)

### 1. Define a Data Model

[](#1-define-a-data-model)

```
// src/DataModel/App.php
namespace App\DataModel;

use System\Core\Data\DataRecord;

class App extends DataRecord
{
    public $id;
    public $name;
    public $version;
    public $description;
    public $author;
    public $created_at;
    public $updated_at;

    public function table(): string { return 'app'; }
    public function primaryKey(): string { return 'id'; }
}
```

### 2. Create a Controller

[](#2-create-a-controller)

```
// src/Module/App/Controller/AppController.php
namespace App\Module\App\Controller;

use App\Module\App\View\AppView;
use System\Core\Base\Controller\Controller;

class AppController extends Controller
{
    public function indexPage()
    {
        $view = new AppView();
        $view->addContents($view->getHomePage());
        return $view->get();
    }
}
```

### 3. Register Routes

[](#3-register-routes)

```
// src/Module/App/routes.php
use Router\Router;

return [
    ['/', 'app/indexPage'],
    ['/home', 'app/indexPage2'],
];
```

### 4. Service Registration

[](#4-service-registration)

Services are reusable components (like database connections, mailers, etc.) that you can register and inject throughout your application.

- Register your services in each module’s `services.php` file (e.g., `src/Module/App/services.php`):

```
// src/Module/App/services.php
return [
    'appService' => function() {
        return new \App\Service\AppService();
    },
    'bookService' => BookService::class,
    'test' => [
        'class' => Test::class,
        'params' => [
            'param1' => 'value1',
            'param2' => 'value2',
        ],
        'singleton' => true
    ]
    // Add more services here
];
```

- The framework will automatically load and make these services available for dependency injection or via the service locator.
- You can retrieve them anywhere using Container as follows

```
$test = Container::get(Test::class);

```

---

### 5. Autoload Registration

[](#5-autoload-registration)

Autoload registration allows you to define additional files as helpers or classes(Model, Service, Library) that should be loaded automatically when your module is initialized.

- Register autoloads in each module’s `autoloads.php` file (e.g., `src/Module/Crud/autoloads.php`):

```
// src/Module/Crud/autoloads.php
return [
    'helper' => [
        __DIR__ . '/Helper/CrudHelper.php',
    ],
    'service' => [
        'app' => AppService::class
    ],
    'model' => [
        'app' => App::class
    ],
    'library' => [
        'Cache' => Cache::class
    ]
];
```

**usage**

```
public class AppController {
    public function action() {
        $service = $this->load->service->app; // AppService object.
        $model = $this->load->model->app; // App object.
        $library = $this->load->library->cache; // Cache library object.

        // to load not registered class
        $this->loader->service(AppService::class);// service
        $this->loader->model(AppModel::class);// model
        $this->loader->library(Library::class); // library
        $this->loader->helper('helper_file.php'); // helper
    }
}
```

- These files will be included automatically when the module is loaded, so you can define helper functions, constants, or perform other setup tasks.

---

### 4. Configure Database

[](#4-configure-database)

Edit your environment config, e.g. `config/dev/db.php`:

```
return [
    'default' => [
        'host' => 'localhost',
        'user' => 'youruser',
        'password' => 'yourpass',
        'database' => 'yourdb',
        'driver' => 'pdo/mysql',
    ]
];
```

### 5. Run Migrations

[](#5-run-migrations)

Place migration files in the `migrations/` directory and run migration as follows.

```
php console/run migrate

```

### 6. Start the Application

[](#6-start-the-application)

Point your web server to the `public/` directory and access your app in the browser.

---

**Tip:**
For more advanced usage, see the `tests/` directory for test cases and the `src/Module/Crud` module for a CRUD example.

---

Command System
--------------

[](#command-system)

The framework includes a powerful command-line system for automation, scaffolding, and database management. All commands are located in:

```
src/Core/Command/

```

### Creating Modules, Migrations, and Commands

[](#creating-modules-migrations-and-commands)

You can scaffold new modules, migrations, and commands using the built-in `create` command:

```
php console/run create:module ModuleName
php console/run create:migration MigrationName
php console/run create:command CommandName
```

This will generate the appropriate directory structure and stub files under `src/Module/ModuleName/`, `migrations/`, or `console/`.

### Running Migrations

[](#running-migrations)

To run or rollback database migrations:

```
php console/run migrate
php console/run rollback
```

### Custom Commands

[](#custom-commands)

You can create your own custom commands using `php console/run create:command `. It will create a command under the `console/` directory and registered in `console/commands.php`.

### Example: Running a Command

[](#example-running-a-command)

```
php console/run
```

This will execute your newly created command.

### Built-in Tool Shortcuts

[](#built-in-tool-shortcuts)

The `console/run` script also provides shortcuts for common tools:

- `php console/run test` — Runs PHPUnit tests
- `php console/run phpstan` — Runs PHPStan static analysis
- `php console/run cs-fixer` — Runs PHP CS Fixer

---

### Contributing

[](#contributing)

Contributions are welcome! If you would like to contribute to gp\_validator, please follow these steps:

- Fork the repository.
- Create a new branch (git checkout -b feature/- YourFeature).
- Make your changes and commit them (git commit -m 'Add some feature').
- Push to the branch (git push origin feature/YourFeature).
- Open a pull request.
- Please ensure that your code adheres to the coding standards and includes appropriate tests.

---

License
-------

[](#license)

This package is licensed under the MIT License. See the [LICENSE](https://github.com/periyandavar/gp_loader/blob/main/LICENSE) file for more information.

---

Contact
-------

[](#contact)

For questions or issues, please reach out to the development team or open a ticket.

---

Author
------

[](#author)

- Periyandavar [Github](https://github.com/periyandavar) ()

---

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance54

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

Every ~28 days

Total

5

Last Release

310d ago

PHP version history (2 changes)v0.0.0PHP ^8.0

0.0.1PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![periyandavar](https://avatars.githubusercontent.com/u/209335631?v=4)](https://github.com/periyandavar "periyandavar (34 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gp-sys/health.svg)

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

###  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)
