PHPackages                             karan-safaie-qadi/backend-system - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. karan-safaie-qadi/backend-system

ActiveLibrary[HTTP &amp; Networking](/categories/http)

karan-safaie-qadi/backend-system
================================

A complete OOP backend management system built on PDO-Module. Full-featured PHP framework for users, products, articles, access control, and more.

v1.0.0(today)10MITPHPPHP &gt;=7.4

Since Jun 22Pushed todayCompare

[ Source](https://github.com/Karan-Safaie-Qadi/Backend-System)[ Packagist](https://packagist.org/packages/karan-safaie-qadi/backend-system)[ Docs](https://github.com/Karan-Safaie-Qadi/Backend-System)[ RSS](/packages/karan-safaie-qadi-backend-system/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (3)Versions (2)Used By (0)

⚡ Backend System
================

[](#-backend-system)

**A Complete Object-Oriented PHP Backend Management System**
**یک سیستم مدیریت بک‌اند تماما شی‌گرا با PHP**

[![PHP](https://camo.githubusercontent.com/f12d1e0bca299be8071ed6dbd1e2766f50138c25b7121117abeb633077a69112/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d254532253839254135372e342d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://php.net)[![License](https://camo.githubusercontent.com/ac049ef4e7a0b7196b09add6ac2d4f180e544c0ac779c2b2ac2fd2723a209579/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75653f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist](https://camo.githubusercontent.com/893b7d39d5ee954323f01d94f3f79c3bd7c3ad367c8c9fa3ab9710dba6c4f22f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7061636b61676973742d76312e302e302d6f72616e67653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/karan-safaie-qadi/backend-system)[![Built on](https://camo.githubusercontent.com/f31f45ee2921622e7c8f42031daf20b944a24508ef0558ee9ce58c9cf88c9d66/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c742532306f6e2d70646f2d2d6d6f64756c652d3663356365373f7374796c653d666c61742d737175617265)](https://packagist.org/packages/karan-safaie-qadi/pdo-module)

---

**English** · [Persian](#%D9%81%D8%A7%D8%B1%D8%B3%DB%8C)

English
-------

[](#english)

A powerful, secure, and extensible OOP backend system built on the [PDO-Module](https://packagist.org/packages/karan-safaie-qadi/pdo-module) package. Designed for rapid backend development with built-in user management, product catalog, article publishing, role-based access control, and more.

### ✨ Features

[](#-features)

FeatureDescription**🔐 User Management**Registration (email/phone mode), login, logout, password reset, profile management**📦 Products**Full CRUD, stock management, pricing, categories, featured/on-sale filters**📝 Articles**Rich content with sections (text, list, table, image, mixed), TOC, publishing workflow**👮 Access Control**3 default roles (user, admin, owner) + fully extensible via config**📧 Email**Integrated PHPMailer for password resets, welcome emails, and notifications**📊 Activity Log**Automatic tracking of all system actions with user and entity context**🔧 System Service**Custom method registry, file uploads, slug generation, input sanitization**🗄️ Database**Secure PDO with prepared statements, transactions, pagination**🌐 Bilingual SPA**Beautiful test panel in Persian &amp; English### 📦 Installation

[](#-installation)

```
composer require karan-safaie-qadi/backend-system
```

### ⚙️ Configuration

[](#️-configuration)

1. Copy `.env.example` to `.env` and configure your database:

```
DB_HOST=localhost
DB_PORT=3306
DB_NAME=my_database
DB_USERNAME=root
DB_PASSWORD=
```

2. Adjust settings in `config/app.php`:

```
'auth' => [
    'registration_mode' => 'email', // 'email' or 'phone'
    'password_min_length' => 8,
],
'access_levels' => [
    1 => 'user',
    2 => 'admin',
    3 => 'owner',
    // 4 => 'editor', // add custom levels
],
```

3. Import the database schema:

```
mysql -u root -p my_database  'johndoe',
    'email' => 'john@example.com',
    'password' => 'securePass123',
    'display_name' => 'John Doe',
]);

// Login
$user = AuthService::login('johndoe', 'securePass123');

// Get current user
$user = AuthService::getCurrentUser();

// Logout
AuthService::logout();
```

#### Managing Products

[](#managing-products)

```
use App\Services\ProductService;

// Create product
$product = ProductService::createProduct([
    'name' => 'Smartphone X',
    'price' => 699.99,
    'stock_quantity' => 50,
    'category_id' => 1,
]);

// Get all products (paginated)
$products = ProductService::getAllProducts(page: 1, perPage: 20);

// Search
$results = ProductService::searchProducts('smartphone');

// Update stock
ProductService::updateStock(1, 100);
```

#### Working with Articles

[](#working-with-articles)

```
use App\Services\ArticleService;

// Create article with sections
$article = ArticleService::createArticle([
    'title' => 'Getting Started with PHP',
    'summary' => 'A comprehensive guide',
    'category_id' => 2,
    'author_id' => 1,
], [
    ['title' => 'Introduction', 'section_type' => 'text', 'content' => 'PHP is a popular language...'],
    ['title' => 'Key Features', 'section_type' => 'list', 'list_items' => ['Easy to learn', 'Widely used', 'Great community']],
    ['title' => 'Comparison', 'section_type' => 'table', 'table_data' => [
        ['Feature', 'PHP', 'Python'], ['Speed', 'Fast', 'Moderate'], ['Learning', 'Easy', 'Easy']
    ]],
]);

// Get article with sections and TOC
$article = ArticleService::getArticle(1);
// $article['sections'] - all sections
// $article['toc'] - table of contents

// Publish
ArticleService::publishArticle(1);
```

#### Access Control

[](#access-control)

```
use App\Auth\AccessControl;

// Check permissions
if (AccessControl::isAdmin($userLevel)) { /* user is admin+ */ }
if (AccessControl::isOwner($userLevel)) { /* user is owner */ }
if (AccessControl::canManageAdmins($userLevel)) { /* only owner */ }

// Enforce minimum level
AccessControl::requireLevel($userLevel, 'admin');

// Custom levels from config
$allLevels = AccessControl::getLevels();   // [1 => 'user', 2 => 'admin', ...]
$levelName = AccessControl::getLevelName(2); // 'admin'
```

#### Custom System Methods

[](#custom-system-methods)

```
use App\Services\SystemService;

// Register custom methods
SystemService::registerMethod('hello', function($name) {
    return "Hello, $name!";
});

// Call them
echo SystemService::callMethod('hello', 'World'); // Hello, World!

// Utility methods
$slug = SystemService::generateSlug('Hello World'); // 'hello-world'
$clean = SystemService::sanitizeInput('alert("xss")');
```

### 🧪 Running the Test SPA

[](#-running-the-test-spa)

Start a PHP development server:

```
php -S localhost:8000 -t public/
```

Open `http://localhost:8000` in your browser. The test panel features:

- 📊 Dashboard with real-time stats
- 👥 User CRUD with search and pagination
- 📦 Product management with stock tracking
- 📝 Article editor with section builder
- ⚙️ System info panel
- 🌐 Bilingual (English/Persian) interface
- 🔄 SPA routing with hash-based navigation

### 🏗️ Architecture

[](#️-architecture)

```
src/
├── Core/              # Base classes
│   ├── Config.php     # Configuration manager (dot-notation access)
│   ├── Model.php      # Base model (extends PDO-Module's Model)
│   ├── Mailer.php     # PHPMailer wrapper
│   └── Session.php    # Session management
├── Auth/
│   └── AccessControl.php  # Role-based access control
├── Models/            # Data models (one per database table)
│   ├── User.php       # Users CRUD + auth helpers
│   ├── Product.php    # Products CRUD + stock/pricing
│   ├── Article.php    # Articles CRUD + publishing
│   ├── ArticleSection.php  # Article sections (text/list/table/image)
│   ├── Category.php   # Hierarchical categories
│   └── ActivityLog.php     # Activity tracking
├── Services/          # Business logic layer
│   ├── AuthService.php     # Authentication & registration
│   ├── UserService.php     # User management
│   ├── ProductService.php  # Product management
│   ├── ArticleService.php  # Article management
│   ├── AdminService.php    # Admin dashboard & operations
│   └── SystemService.php   # Custom methods & utilities
└── Traits/
    └── HasTimestamps.php    # Timestamps trait

```

### 📄 Database Schema

[](#-database-schema)

The full schema is in `migrations/schema.sql` with 7 tables:

TablePurpose`users`User accounts with roles and auth tokens`categories`Hierarchical categories for products &amp; articles`products`Product catalog with pricing, stock, images`articles`Content articles with metadata`article_sections`Rich content sections (text, list, table, image)`activity_logs`System-wide activity tracking`settings`Key-value application settings### 🛠️ Development

[](#️-development)

```
# Install dependencies
composer install

# Run tests
./vendor/bin/phpunit

# Check syntax
find src -name "*.php" -exec php -l {} \;
```

### 📝 License

[](#-license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

### 👤 Author

[](#-author)

**Karan Safaie Qadi**

- GitHub: [@Karan-Safaie-Qadi](https://github.com/Karan-Safaie-Qadi)
- Packagist: [karan-safaie-qadi](https://packagist.org/packages/karan-safaie-qadi/)

---

فارسی
-----

[](#فارسی)

یک سیستم مدیریت بک‌اند قدرتمند، امن و قابل گسترش مبتنی بر [PDO-Module](https://packagist.org/packages/karan-safaie-qadi/pdo-module). طراحی شده برای توسعه سریع بک‌اند با قابلیت‌های مدیریت کاربران، محصولات، مقالات، کنترل دسترسی سطح‌بندی شده و موارد دیگر.

### ✨ ویژگی‌ها

[](#-ویژگی‌ها)

ویژگیتوضیحات**🔐 مدیریت کاربران**ثبت‌نام با دو حالت (ایمیل/شماره تلفن اجباری)، ورود و خروج، بازیابی رمز عبور**📦 محصولات**مدیریت کامل، موجودی، قیمت‌گذاری، دسته‌بندی، فیلتر ویژه/تخفیف**📝 مقالات**محتوای غنی با بخش‌های متنوع (متن، لیست، جدول، تصویر)، فهرست مطالب**👮 کنترل دسترسی**۳ نقش پیش‌فرض (کاربر، مدیر، مالک) + قابلیت افزودن نقش جدید از طریق کانفیگ**📧 ایمیل**PHPMailer یکپارچه برای بازیابی رمز و اطلاع‌رسانی**📊 لاگ فعالیت**ثبت خودکار تمام عملیات با جزئیات کاربر و موجودیت**🔧 سیستم سفارشی**ثبت متدهای دلخواه، آپلود فایل، تولید slug، پالایش ورودی**🗄️ دیتابیس**PDO امن با Prepared Statements، تراکنش، صفحه‌بندی**🌐 پنل دو زبانه**SPA زیبا برای تست با پشتیبانی فارسی و انگلیسی### 📦 نصب

[](#-نصب)

```
composer require karan-safaie-qadi/backend-system
```

### ⚙️ تنظیمات

[](#️-تنظیمات)

۱. فایل `.env.example` را به `.env` کپی کنید و اطلاعات دیتابیس را تنظیم کنید:

```
DB_HOST=localhost
DB_PORT=3306
DB_NAME=my_database
DB_USERNAME=root
DB_PASSWORD=
```

۲. تنظیمات را در `config/app.php` شخصی‌سازی کنید:

```
'auth' => [
    'registration_mode' => 'email', // 'email' یا 'phone'
    'password_min_length' => 8,
],
'access_levels' => [
    1 => 'user',
    2 => 'admin',
    3 => 'owner',
    // 4 => 'editor', // سطوح دلخواه اضافه کنید
],
```

۳. اسکیمای دیتابیس را اجرا کنید:

```
mysql -u root -p my_database  'ali',
    'email' => 'ali@example.com',
    'password' => '12345678',
]);

// ورود
$user = AuthService::login('ali', '12345678');

// خروج
AuthService::logout();
```

#### مدیریت محصولات

[](#مدیریت-محصولات)

```
use App\Services\ProductService;

// ایجاد محصول
$product = ProductService::createProduct([
    'name' => 'گوشی هوشمند X',
    'price' => 25000000,
    'stock_quantity' => 50,
]);

// جستجو
$results = ProductService::searchProducts('گوشی');
```

#### مقالات

[](#مقالات)

```
use App\Services\ArticleService;

$article = ArticleService::createArticle([
    'title' => 'آموزش PHP',
    'summary' => 'یک راهنمای جامع',
], [
    ['title' => 'مقدمه', 'section_type' => 'text', 'content' => 'PHP یک زبان محبوب است...'],
    ['title' => 'ویژگی‌ها', 'section_type' => 'list', 'list_items' => ['آسان', 'قدرتمند', 'رایگان']],
]);
```

### 🧪 اجرای پنل تست

[](#-اجرای-پنل-تست)

```
php -S localhost:8000 -t public/
```

سپس در مرورگر به آدرس `http://localhost:8000` مراجعه کنید.

### 👤 نویسنده

[](#-نویسنده)

**کاران صفایی قادی**

- گیت‌هاب: [@Karan-Safaie-Qadi](https://github.com/Karan-Safaie-Qadi)

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/288579950?v=4)[Karan Safaie Qadi](/maintainers/Karan-Safaie-Qadi)[@Karan-Safaie-Qadi](https://github.com/Karan-Safaie-Qadi)

---

Top Contributors

[![Karan-Safaie-Qadi](https://avatars.githubusercontent.com/u/288579950?v=4)](https://github.com/Karan-Safaie-Qadi "Karan-Safaie-Qadi (123 commits)")

---

Tags

phpapirestauthpdocmsUsersbackendarticlesproductsmanagement system

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/karan-safaie-qadi-backend-system/health.svg)

```
[![Health](https://phpackages.com/badges/karan-safaie-qadi-backend-system/health.svg)](https://phpackages.com/packages/karan-safaie-qadi-backend-system)
```

PHPackages © 2026

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