PHPackages                             sadeghb97/avetify - 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. sadeghb97/avetify

ActiveLibrary[Framework](/categories/framework)

sadeghb97/avetify
=================

A lightweight and easy to use framework on PHP.

v0.1.9(3mo ago)056MITPHPPHP &gt;=8.0

Since May 24Pushed 3w ago1 watchersCompare

[ Source](https://github.com/sadeghb97/avetify)[ Packagist](https://packagist.org/packages/sadeghb97/avetify)[ Docs](https://github.com/sadeghb97/avetify)[ RSS](/packages/sadeghb97-avetify/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (11)Used By (0)

Avetify
=======

[](#avetify)

**Avetify** is a lightweight PHP framework for building data-driven admin panels and internal tools. It uses plain PHP (no full-stack MVC stack), renders HTML directly, and centers on three building blocks—**entities** (record forms), **tables** (editable grids), and **listers** (sortable collections)—backed by MySQL via `mysqli`.

**PHP**`>= 8.2`**License**MIT**Version**`0.1.0` (build `1`)**Package**[`sadeghb97/avetify`](https://github.com/sadeghb97/avetify)---

Table of contents
-----------------

[](#table-of-contents)

- [Philosophy](#philosophy)
- [Requirements](#requirements)
- [Installation](#installation)
- [Project layout](#project-layout)
- [Bootstrapping](#bootstrapping)
- [Core concepts](#core-concepts)
- [Building a page](#building-a-page)
- [Themes and assets](#themes-and-assets)
- [Extending the framework](#extending-the-framework)
- [Additional modules](#additional-modules)
- [Scaffolding scripts](#scaffolding-scripts)
- [Examples](#examples)
- [License](#license)

---

Philosophy
----------

[](#philosophy)

Avetify is intentionally small and explicit:

- **No magic router** — each screen is a PHP entry file (e.g. `records.php`, `item.php`).
- **Server-rendered UI** — pages are built with PHP classes that echo HTML through `HTMLInterface` and theme renderers.
- **MySQL-first** — `DBConnection` extends `mysqli` with helpers; `QueryBuilder` and filter collections compose SQL.
- **Composable UI** — tables, entity forms, and listers share sorting, filtering, and pagination via `SetModifier`.
- **Extend in the host app** — domain logic, custom table fields, themes, and navigation live in the consuming project’s `lib/` tree.

---

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

[](#requirements)

### PHP extensions

[](#php-extensions)

ExtensionPurpose`mysqli`Database access`gd`Image processing`fileinfo`MIME detection`exif`Image metadata`posix`, `pcntl`CLI / background tasks### Runtime

[](#runtime)

- PHP **8.2+**
- MySQL or MariaDB
- A web server (Apache/Nginx) or PHP CLI for scripts

---

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

[](#installation)

Avetify supports two integration styles.

### Option A — Git clone (sibling directory)

[](#option-a--git-clone-sibling-directory)

Clone the framework next to your app and load the monolithic bootstrap:

```
cd /path/to/htdocs/your-project
git clone https://github.com/sadeghb97/avetify.git avetify
```

Add `avetify` to your project `.gitignore` if you treat it as a vendored dependency.

Or use the helper script from the framework repo:

```
/path/to/avetify/avtclone   # clones into ./avetify
```

### Option B — Composer

[](#option-b--composer)

```
composer require sadeghb97/avetify:dev-main
```

Composer autoloads the `Avetify\` PSR-4 namespace from `src/`. You still need to initialize paths and expose static assets (see [Bootstrapping](#bootstrapping) and [Themes and assets](#themes-and-assets)).

### Quick scaffold

[](#quick-scaffold)

From a directory under `htdocs/`, run `avtcreate` (see [Scaffolding scripts](#scaffolding-scripts)) to clone Avetify and generate starter `lib/lib.php`, `*Connection.php`, `avetify.php`, and `index.php`.

---

Project layout
--------------

[](#project-layout)

A typical consuming application looks like this:

```
your-project/
├── avetify/              # cloned framework (Option A) or vendor/sadeghb97/avetify (Option B)
├── avetify.php           # optional front controller
├── index.php             # often redirects to avetify.php
├── lib/
│   ├── lib.php           # bootstrap: init manager, require domain code
│   ├── YourConnection.php
│   ├── entities/         # AvtEntity subclasses
│   ├── tables/           # DBTable subclasses
│   ├── listers/          # DBLister subclasses
│   ├── models/           # DataModel subclasses
│   ├── fields/           # custom table/entity fields
│   └── theme/            # ThemesManager subclass, navigation
├── records.php           # example page: table view
├── item.php              # example page: entity form
└── .avtfiles/            # runtime uploads/backups (created by Routing)

```

The framework itself is organized as:

```
avetify/
├── avetify.php           # explicit require_once bootstrap (all classes)
├── assets/               # CSS, JS, fonts, themes (main, green, modern, …)
├── data/                 # bundled datasets (e.g. countries)
├── src/
│   ├── AvetifyManager.php
│   ├── DB/               # DBConnection, QueryBuilder, filters
│   ├── Entities/         # AvtEntity, fields, sorters, filters
│   ├── Table/            # AvtTable, DBTable, field types
│   ├── Lister/           # AvtLister, DBLister
│   ├── Themes/           # Green, Modern, Modernix, Classic, …
│   ├── Components/       # dialogs, charts, selectors, cropper, …
│   ├── Forms/, Auth/, Api/, GalRepo/, Standings/, …
│   └── …
├── avtcreate, avtclone
└── composer.json

```

---

Bootstrapping
-------------

[](#bootstrapping)

Every app must call `AvetifyManager::init()` once during startup.

```
use Avetify\AvetifyManager;

// $basePath: project root on disk
// $publicPath: web-accessible root (often same as base)
// $publicUrl: URL prefix for the app, e.g. "/my-admin"
// $assetUrl: URL prefix for framework assets, e.g. "/avetify/assets"

AvetifyManager::init(__DIR__, __DIR__, '/my-admin', '/avetify/assets');
```

### Option A — full bootstrap

[](#option-a--full-bootstrap)

```
require_once __DIR__ . '/../avetify/avetify.php';

use Avetify\AvetifyManager;

AvetifyManager::init(__DIR__, __DIR__, '/my-admin', '/avetify/assets');

require_once __DIR__ . '/YourConnection.php';
// … require entities, tables, themes, etc.
```

`avetify.php` registers every framework class via `require_once` (no Composer autoload needed).

### Option B — Composer autoload

[](#option-b--composer-autoload)

```
require_once __DIR__ . '/../vendor/autoload.php';

use Avetify\AvetifyManager;

AvetifyManager::init(dirname(__DIR__), dirname(__DIR__), '/my-admin', '/avetify/assets');
```

Use `use Avetify\…` imports for framework types. Ensure `/avetify/assets` is mapped in your web server to the framework `assets/` directory (clone path or `vendor/sadeghb97/avetify/assets`).

### Database connection

[](#database-connection)

Subclass `DBConnection` and implement credentials:

```
use Avetify\DB\DBConnection;

class YourConnection extends DBConnection {
    public function getHost(): string { return 'localhost'; }
    public function getUser(): string { return 'root'; }
    public function getPassword(): string { return ''; }
    public function getDBName(): string { return 'your_database'; }
}
```

`DBConnection` provides `fetchRow`, `fetchSet`, `fetchMap`, `fetchAvtSet`, filter-aware queries, and a singleton via `getInstance()`.

You can add domain-specific query methods on your connection subclass (filtered lists, joins, aggregates) and call them from `fetchDBRecords()` or entity loaders.

---

Core concepts
-------------

[](#core-concepts)

### SetModifier — shared behavior

[](#setmodifier--shared-behavior)

`AvtTable`, `AvtLister`, and entity/set views inherit from `SetModifier`, which handles:

- URL-driven **sorting** (`?{setKey}_sort=…`)
- **Filtering** via filter factors and discrete qualifiers
- **Pagination** through `PaginationConfigs`
- **Rendering** through a `SetRenderer` and `renderPage($title)`

### Tables (`DBTable`)

[](#tables-dbtable)

Editable admin grids bound to a MySQL table. On construction, `DBTable` loads field definitions, fetches rows, and can persist inline edits through `QueryBuilder`.

Typical subclass responsibilities:

MethodRole`makeTableFields()`Column definitions (`EditableField`, `ExtendedAvatarField`, custom fields, …)`fetchDBRecords()`Rows to display (from the DB table or custom SQL on your connection)`getItemLink()`Link from a row to a detail page`getTableRenderer()`Optional theme overrideOverride `fetchDBRecords()` when you need joins, aggregates, or query-string filters (e.g. `?category=…`). Keep filtering logic in your connection or table class, not in the framework core.

### Entities (`AvtEntity`)

[](#entities-avtentity)

Single-record create/edit forms with field metadata, validation hooks, image handling, and optional redirect after insert.

Typical subclass responsibilities:

MethodRole`getTableName()` / `getSuperKey()`DB mapping`dataFields()`Writable `EntityTextField`, `EntitySelectField`, wrappers, …`getTheme()``ThemesManager` for layout and assets`renderEntityPage()`Renders the full entity UIA detail page is usually a thin entry script: bootstrap, `new YourEntity($conn)`, then `renderEntityPage()`.

### Listers (`DBLister`)

[](#listers-dblister)

Ordered, often drag-aware lists backed by the database—used for priorities, categories, and gallery ordering.

Subclass `DBLister`, implement category/sort mapping methods, and return items from `fetchAllItems()`. Attach a custom theme when you need extra JS (e.g. coding or markdown tools).

### Models (`DataModel`)

[](#models-datamodel)

Typed row objects with hydration from associative arrays, usually created via `AvtEntityItem::mapArray(YourModel::class, $rows)`.

### Routing

[](#routing)

`Avetify\Routing\Routing` provides URL/path helpers: `publicUrl`, `serverRootPath`, query param add/remove, HTTPS detection, and `.avtfiles/` backup directory resolution.

### HTML layer

[](#html-layer)

`HTMLInterface`, `Styler`, `WebModifier`, and `Placeable` components generate markup without a template engine. Custom fields implement `place()` / rendering hooks and attach CSS or JS through the active theme.

---

Building a page
---------------

[](#building-a-page)

### Table listing page

[](#table-listing-page)

```
