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

ActiveProject[Framework](/categories/framework)

wafwork/wafwork
===============

A lightweight PHP MVC framework inspired by Laravel

v1.0.1(1y ago)11MITPHPPHP ^7.4|^8.0

Since Apr 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/wasishah33/wafwork)[ Packagist](https://packagist.org/packages/wafwork/wafwork)[ Docs](https://github.com/wasishah33/wafwork)[ RSS](/packages/wafwork-wafwork/feed)WikiDiscussions main Synced 1mo ago

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

WAFWork - Minimal PHP MVC Framework
===================================

[](#wafwork---minimal-php-mvc-framework)

[![Latest Version on Packagist](https://camo.githubusercontent.com/57d0bd9f11c200156e94c85ac0226868a19f29e9fac8e78841bd1f314265d8c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776166776f726b2f776166776f726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wafwork/wafwork)[![Total Downloads](https://camo.githubusercontent.com/761682e515316a9c164d51fe4102abd7b6b71b722254ef59921767eb2e39808a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776166776f726b2f776166776f726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wafwork/wafwork)[![License](https://camo.githubusercontent.com/669d85a050b98fbb8c95ddd5f49919f822c1639a5532818708db120b32899c22/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f776166776f726b2f776166776f726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wafwork/wafwork)

WAFWork is a lightweight PHP MVC framework inspired by Laravel, designed for fast performance and minimal overhead while maintaining essential functionality.

Features
--------

[](#features)

- **MVC Architecture** - Clean separation of concerns with Models, Views, and Controllers
- **Simple &amp; Intuitive Routing** - Express-style routing with support for all HTTP methods
- **Database Abstraction Layer** - Simple ORM implementation with fluent query builder
- **Template Engine** - Blade-like syntax for views with layouts, sections, and includes
- **Dependency Injection Container** - Service container for managing class dependencies
- **Environment Configuration** - Support for .env files to manage environment variables
- **Helper Functions** - Laravel-inspired helper functions for common tasks
- **Middleware Support** - Request/response filters with middleware pattern

Versioning
----------

[](#versioning)

WAFWork follows [Semantic Versioning](https://semver.org/). Version numbers are in the format of MAJOR.MINOR.PATCH:

- **MAJOR**: Incompatible API changes
- **MINOR**: Add functionality in a backward-compatible manner
- **PATCH**: Backward-compatible bug fixes

Check [releases page](https://github.com/wasishah33/wafwork/releases) for the latest version.

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

[](#directory-structure)

```
wafwork3/
├── app/                  # Application code
│   ├── Controllers/      # Controller classes
│   ├── Models/           # Model classes
│   ├── Middleware/       # Middleware classes
│   ├── Views/            # View templates
│   │   └── layouts/      # Layout templates
│   └── Helpers/          # Helper functions
├── config/               # Configuration files
├── database/             # Database migrations and seeds
├── framework/            # Core framework code
│   ├── Core/             # Core components
│   ├── Database/         # Database components
│   ├── Http/             # HTTP components
│   └── View/             # View components
├── public/               # Publicly accessible files
│   └── index.php         # Entry point
├── routes/               # Route definitions
│   └── web.php           # Web routes
├── storage/              # Storage for logs, cache, etc.
├── vendor/               # Dependencies (Composer)
├── .env                  # Environment variables
└── composer.json         # Composer dependencies

```

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

[](#installation)

### Requirements

[](#requirements)

- PHP 7.4 or higher
- Composer
- PDO PHP Extension

### Install via Packagist (Recommended)

[](#install-via-packagist-recommended)

The easiest way to install WAFWork is through Composer:

```
# Create a new project
composer create-project wafwork/wafwork your-project-name

# OR add to an existing project
composer require wafwork/wafwork
```

You can also specify a specific version:

```
# Install specific version
composer create-project wafwork/wafwork:^1.0 your-project-name
```

After installation, the directory structure will be automatically created, and you'll be ready to start building your application.

### Manual Installation

[](#manual-installation)

1. Clone the repository:

```
git clone https://github.com/wasishah33/wafwork.git your-project-name
cd your-project-name
```

2. Install the dependencies:

```
composer install
```

3. Create your environment file:

```
cp .env.example .env
```

4. Configure your environment variables in the `.env` file:

```
APP_NAME=YourAppName
APP_ENV=development
APP_DEBUG=true
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
```

5. Set proper permissions:

```
chmod -R 775 storage
```

6. Configure your web server:

**Apache**

Ensure your Apache configuration points to the `public` directory and that `.htaccess` is enabled with `mod_rewrite`.

Example `.htaccess` for the public directory:

```

        Options -MultiViews -Indexes

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

```

**Nginx**

```
server {
    listen 80;
    server_name your-domain.com;
    root /path/to/your-project/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}
```

7. Visit your site in a browser and verify the installation.

Basic Usage
-----------

[](#basic-usage)

### Routes

[](#routes)

Routes are defined in the `routes/web.php` file:

```
// routes/web.php
$router->get('/', 'HomeController@index');
$router->post('/users', 'UserController@store');
$router->get('/users/{id}', 'UserController@show');
```

### Controllers

[](#controllers)

Controllers handle the incoming requests and return responses:

```
// app/Controllers/UserController.php
namespace App\Controllers;

use WAFWork\Http\Controller;
use WAFWork\Http\Request;
use App\Models\User;

class UserController extends Controller
{
    public function index(Request $request)
    {
        $users = User::all();
        return $this->view('users.index', ['users' => $users]);
    }

    public function show(Request $request)
    {
        $user = User::find($request->param('id'));
        return $this->view('users.show', ['user' => $user]);
    }
}
```

### Models

[](#models)

Models represent database tables and provide an ORM interface:

```
// app/Models/User.php
namespace App\Models;

use WAFWork\Database\Model;

class User extends Model
{
    protected $table = 'users';
    protected $fillable = ['name', 'email', 'password'];

    // Define relationships or custom methods
    public function posts()
    {
        // Relationship implementation
    }
}

// Usage
$users = User::all();
$user = User::find(1);
$activeUsers = User::where('status', 'active');

$user = new User(['name' => 'John', 'email' => 'john@example.com']);
$user->save();
```

### Views

[](#views)

Views use a Blade-like template syntax:

```

@extends('layouts.app')

@section('title', 'Users')

@section('content')
    Users

        @foreach($users as $user)
            {{ $user->name }} - {{ $user->email }}
        @endforeach

@endsection
```

### Middleware

[](#middleware)

Middleware provides a mechanism to filter HTTP requests:

```
// app/Middleware/AuthMiddleware.php
namespace App\Middleware;

use WAFWork\Http\Middleware;
use WAFWork\Http\Request;
use WAFWork\Http\Response;

class AuthMiddleware implements Middleware
{
    public function handle(Request $request, callable $next)
    {
        if (!isset($_SESSION['user_id'])) {
            return redirect('/login');
        }

        return $next($request);
    }
}

// Usage in routes
$router->get('/dashboard', 'DashboardController@index')->middleware('auth');
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

Staying Up-to-Date
------------------

[](#staying-up-to-date)

To ensure you're using the latest version of WAFWork, regularly update your installation:

```
composer update wafwork/wafwork
```

You can check for available updates without actually installing them:

```
composer outdated wafwork/wafwork
```

Security
--------

[](#security)

If you discover a security vulnerability within WAFWork, please send an email to Wasif Waheed at . All security vulnerabilities will be promptly addressed.

Upgrading
---------

[](#upgrading)

When upgrading between major versions of the framework, please review the [upgrade guide](https://github.com/wasishah33/wafwork/blob/master/UPGRADING.md) for specific instructions.

Community
---------

[](#community)

- [GitHub Discussions](https://github.com/wasishah33/wafwork/discussions)
- [GitHub Issues](https://github.com/wasishah33/wafwork/issues)

License
-------

[](#license)

This project is licensed under the MIT License - see the LICENSE file for details.

Credits
-------

[](#credits)

WAFWork is inspired by Laravel and other PHP frameworks, with the goal of providing a lightweight alternative that maintains essential functionality.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance47

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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 ~0 days

Total

2

Last Release

393d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

phpframeworklaravelmvclightweight

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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