PHPackages                             samphp/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. samphp/framework

ActiveProject[Framework](/categories/framework)

samphp/framework
================

SamPHP — A lightweight, secure, MVC-based PHP framework for building CRMs, websites, and APIs with zero bloat.

v1.0.0(1mo ago)011MITPHPPHP &gt;=7.4

Since May 9Pushed 1mo agoCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

 **SamPHP Framework**
 A lightweight, secure, MVC-based PHP framework for building CRMs, websites, and APIs.

 [![Latest Version](https://camo.githubusercontent.com/8d69a3269b19012b6497938f34121b571f7772e3f3e98d5bd0ff1b1ce228cab2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73616d7068702f6672616d65776f726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/samphp/framework) [![Total Downloads](https://camo.githubusercontent.com/2493141f1af0432b40351c100ee2332a8e3f1775cabec85e034b39c4e2a5d6c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73616d7068702f6672616d65776f726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/samphp/framework) [![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE) [![PHP Version](https://camo.githubusercontent.com/47f8d2c7cb2fc1fee982145fe79ad242cd127cdb3025b0ad9e6bcaf460a92fb4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344372e342d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/47f8d2c7cb2fc1fee982145fe79ad242cd127cdb3025b0ad9e6bcaf460a92fb4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344372e342d3838393242462e7376673f7374796c653d666c61742d737175617265)

---

✨ Features
----------

[](#-features)

- **MVC Architecture** — Clean separation of Models, Views, and Controllers
- **Built-in Security** — CSRF protection, XSS sanitization, bcrypt password hashing
- **Session Management** — Secure session handling with regeneration &amp; flash messages
- **Middleware System** — Auth, Guest, and Role-based access control out of the box
- **Input Validation** — Server-side validation (required, email, min, max, numeric, url, regex)
- **PDO Database Layer** — Secure MySQL connection with singleton pattern &amp; prepared statements
- **Modern Frontend** — Outfit font, Lucide icons, toast notifications, modal system
- **AJAX Utilities** — Built-in JavaScript helpers for API calls and form handling
- **Clean URLs** — Apache mod\_rewrite routing with directory protection
- **Zero Dependencies** — Pure PHP, no external packages required

📦 Installation
--------------

[](#-installation)

### Via Composer (Recommended)

[](#via-composer-recommended)

```
composer create-project samphp/framework your-project-name
```

This will:

1. Download the framework template
2. Auto-create `config/config.php` from the sample
3. Display next-step instructions

### Manual Installation

[](#manual-installation)

```
git clone https://github.com/samaponghosh/samphp-framework.git your-project-name
cd your-project-name
cp config/config.sample.php config/config.php
```

⚙️ Configuration
----------------

[](#️-configuration)

Edit `config/config.php` with your settings:

```
// Application
define('APP_NAME', 'My Application');
define('BASE_URL', 'http://localhost/your-project-name/public');

// Database
define('DB_HOST', 'localhost');
define('DB_NAME', 'your_database');
define('DB_USER', 'root');
define('DB_PASS', '');

// Timezone
date_default_timezone_set('UTC');

// Error Reporting — Set to 0 in production!
error_reporting(E_ALL);
ini_set('display_errors', 1);
```

📂 Project Structure
-------------------

[](#-project-structure)

```
your-project-name/
├── app/
│   ├── controllers/        # Your controllers
│   │   └── HomeController.php
│   ├── core/               # Framework core (do not modify)
│   │   ├── App.php         # Front controller & URL router
│   │   ├── Controller.php  # Base controller class
│   │   ├── Database.php    # PDO database connection (singleton)
│   │   ├── Mailer.php      # Email helper (extendable)
│   │   ├── Model.php       # Base model class
│   │   ├── Router.php      # Route definitions (extendable)
│   │   ├── Security.php    # CSRF, XSS, password hashing
│   │   ├── Session.php     # Session management + flash messages
│   │   └── Validator.php   # Input validation
│   ├── middleware/          # Request middleware
│   │   ├── AuthMiddleware.php
│   │   ├── GuestMiddleware.php
│   │   └── RoleMiddleware.php
│   ├── models/             # Your models
│   └── views/              # Your views
│       ├── home/
│       │   └── index.php
│       └── layouts/
│           ├── header.php
│           ├── footer.php
│           ├── navbar.php
│           └── sidebar.php
├── config/
│   ├── config.sample.php   # Template config (committed)
│   ├── constants.php       # Path constants (auto-resolved)
│   └── database.php        # Database bootstrap
├── public/                 # Web root (point your server here)
│   ├── assets/
│   │   ├── css/style.css
│   │   ├── js/main.js
│   │   └── images/
│   ├── uploads/            # User uploads
│   ├── .htaccess
│   └── index.php           # Application entry point
├── storage/
│   ├── cache/
│   ├── logs/
│   └── mail_attachments/
├── .htaccess               # Root redirect to public/
├── composer.json
├── LICENSE
└── README.md

```

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Create a Controller

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

```
// app/controllers/ProductController.php
