PHPackages                             wepesi/wepesi - 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. wepesi/wepesi

ActiveProject[Framework](/categories/framework)

wepesi/wepesi
=============

a light way php framework to create simple web application

v3.2.13(4y ago)4272[12 issues](https://github.com/kivudesign/Wepesi/issues)[2 PRs](https://github.com/kivudesign/Wepesi/pulls)MITPHPPHP &gt;=7.4CI passing

Since Nov 12Pushed 4w ago1 watchersCompare

[ Source](https://github.com/kivudesign/Wepesi)[ Packagist](https://packagist.org/packages/wepesi/wepesi)[ Docs](https://github.com/kivudesign/Wepesi-Quick/issues)[ GitHub Sponsors](https://github.com/kivudesign/Wepesi-Quick)[ RSS](/packages/wepesi-wepesi/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)DependenciesVersions (53)Used By (0)

Wepesi
======

[](#wepesi)

Wepesi is a lightweight PHP framework for building web applications using MVC principles. It is designed to be simple, flexible, and easy to get started with — no heavy configuration required.

**Features:**

- Routing (GET, POST, PUT, PATCH, DELETE)
- Controllers
- Simple ORM (no migrations)
- Middleware
- Validation
- View rendering
- Sessions, JWT, and more — all built in

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

[](#table-of-contents)

1. [Installation](#installation)
2. [Project Structure](#project-structure)
3. [Routing](#routing)
4. [Controllers](#controllers)
5. [Database](#database)
6. [Validation](#validation)

---

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

[](#installation)

### Using Composer (recommended)

[](#using-composer-recommended)

Requires PHP &gt;= 8.0. Create a new project with:

```
composer create-project wepesi/wepesi my-project
```

Then open `my-project/` in your web server root and configure your `.env` file (copy `.env.example` to `.env`). At minimum set the database credentials:

```
DB_HOST=127.0.0.1
DB_NAME=your_database
DB_USER=your_user
DB_PASSWORD=your_password
DB_PORT=3306
APP_ENV=dev
LANG=en
```

### Manual Setup

[](#manual-setup)

1. Download or clone the repository:

    ```
    git clone https://github.com/kivudesign/Wepesi.git my-project
    ```
2. Copy the environment file and fill in your settings:

    ```
    cp .env.example .env
    ```
3. Place the project folder in your web server's document root:

    - **WAMP**: `C:/wamp/www/my-project`
    - **XAMPP**: `C:/xampp/htdocs/my-project`
    - **Linux/macOS Apache/Nginx**: configure a virtual host pointing to the project root
4. Navigate to `http://localhost/my-project` in your browser.

> No extra modules or build steps are needed. The `.htaccess` file handles URL rewriting automatically.

---

Project Structure
-----------------

[](#project-structure)

```
my-project/
├── app/
│   ├── Controller/       # Your controllers
│   ├── Models/           # Your entity/model classes
│   ├── Middleware/       # Request middleware
│   ├── Routes/
│   │   ├── web.php       # Web routes
│   │   └── api.php       # API routes
│   └── Views/            # HTML view templates
├── config/               # Database and autoload configuration
├── src/                  # Framework core (do not modify)
├── .env                  # Environment variables
├── .htaccess             # URL rewriting
└── index.php             # Application entry point

```

---

Routing
-------

[](#routing)

Routes are defined in `app/Routes/web.php` (web) or `app/Routes/api.php` (API). The `$router` object is available via `$app->router()`.

### Basic routes

[](#basic-routes)

```
// Closure handler
$router->get('/', function () {
    echo 'Hello World!';
});

$router->post('/submit', function () {
    // handle POST request
});
```

### Route with a dynamic parameter

[](#route-with-a-dynamic-parameter)

```
$router->get('/users/:id', function ($id) {
    echo 'User ID: ' . $id;
});
```

Constrain the parameter to digits only using `->with()`:

```
$router->get('/users/:id', function ($id) {
    echo 'User ID: ' . $id;
})->with('id', '[0-9]+');
```

### Route to a controller method

[](#route-to-a-controller-method)

```
use App\Controller\UserController;

$router->get('/users', [UserController::class, 'index']);
$router->post('/users', [UserController::class, 'store']);
```

### Route groups

[](#route-groups)

```
$router->group('/admin', function () use ($router) {
    $router->get('/', [AdminController::class, 'dashboard']);
    $router->get('/users', [AdminController::class, 'users']);
});
```

### Middleware on a route

[](#middleware-on-a-route)

```
use App\Middleware\AuthMiddleware;

$router->get('/dashboard', [DashboardController::class, 'index'])
    ->middleware([AuthMiddleware::class, 'handle']);
```

### API routes

[](#api-routes)

Routes defined inside `$router->api()` are automatically prefixed with `/api`:

```
use Wepesi\Core\Routing\Router;

$router->api(function (Router $router) {
    $router->group('/v1', function (Router $router) {
        $router->get('/users', [UserController::class, 'index']);
    });
});
// Resolves to: /api/v1/users
```

### Custom 404 handler

[](#custom-404-handler)

```
use Wepesi\Core\Http\Response;

$router->set404(function () {
    Response::send('Route not found', 404);
});
```

---

Controllers
-----------

[](#controllers)

Controllers live in `app/Controller/` and extend `Wepesi\Core\Http\Controller`.

```
