clintonnzedimma / woski
Woski is a simple fast PHP framework for the Realm.
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 20
Watchers: 5
Forks: 2
Open Issues: 1
Type:project
Requires
- php: >=7.4
- filp/whoops: ^2.7
- vlucas/phpdotenv: ^4.1
This package is auto-updated.
Last update: 2025-05-25 19:06:22 UTC
README
Woski is a simple fast PHP framework for the Realm
The Project
🚀 Features
- PSR-4 Autoloading via Composer
- Express-style Routing
- HTTP verbs:
get
,post
,put
,patch
,delete
,any
- Route groups:
$app->use('/admin', _import('routes/admin.routes.php'))
- HTTP verbs:
- Middleware Pipeline
- Global middleware:
$app->use([$mw->handle])
- Route-specific & group middleware
Next
/Block
control flow- Debug logging with
WOSKIPHP_MIDDLEWARE_DEBUG=true
- Global middleware:
- Error Handling
- Custom 404 handlers per method or global via
$app->error()
- Custom 404 handlers per method or global via
- Request & Response Objects
$req->body
,$req->query
,$req->files
,$req->cookies
$req->hasFile('avatar')
,$req->isImage('avatar')
$res->json()
,$res->send()
,$res->sendStatus()
- Input Validation
validate($req->body, [...rules...])
with aliases
- File Uploads
- Easy retrieval:
Request::file('avatar')
- Easy retrieval:
- Configuration & .env
env('KEY', $default)
andconfig('app.name')
helpers- All core vars prefixed
WOSKIPHP_
- Logging
logger()->info()
,warning()
,error()
,debug()
→storage/logs/woski.log
- CLI Tooling (
php woski ...
)--run [--port=]
→ quick dev server--make:controller=Name
--make:middleware=Name
--help
📦 Installation
git clone https://github.com/your-username/woski.git cd woski composer install cp .env.example .env # configure as needed mkdir -p storage/logs # ensure log folder exists
⚙️ Quick Start
-
Bootstrap & start:
// index.php (or public/index.php) require 'core/woski.php'; $app = new Woski\Application; // Global middleware example // $app->use([$demoMW->handle]); // Basic route $app->get('/', [$homeController->index]); // Grouped routes $app->use('/example', [$demoMW->foo], _import('routes/example.routes.php')); // 404 handler $app->error(['GET','POST','PUT','PATCH'], function($req, $res) { $res->sendStatus(404); return $res->json(['error'=>'Not found']); }); $app->start();
-
Run dev server:
php woski --run # default port 3000 or WOSKIPHP_PORT php woski --run --port=8xxx
-
Generate code:
php woski --make:controller UserController php woski --make:middleware AuthMiddleware php woski --make:model User --table=users
🛠 Configuration
- Core .env variables must be prefixed
WOSKIPHP_
, e.g.:WOSKIPHP_PORT=4000 WOSKIPHP_MIDDLEWARE_DEBUG=true
- config/app.php returns an array you can access via:
config('app.name'); // "WoskiPHP" config('app.debug'); // true/false
🔒 Request Validation
$errors = validate($req->body, [ 'email' => 'required|email:Email Address', 'password' => 'required|min:6:Password', ]); if ($errors) { return $res->json(['errors'=>$errors], 422); }
🗂 File Uploads
if ($req->hasFile('avatar') && $req->isImage('avatar')) { $file = $req->files['avatar']; move_uploaded_file($file['tmp_name'], 'uploads/'.$file['name']); return $res->json(['message'=>'Uploaded']); }
🧑💻 Contributing
- Fork the repo
- Create a feature branch (
git checkout -b feature/...
) - Commit your changes (
git commit -m 'Add ...'
) - Push to the branch (
git push
) - Open a Pull Request
📄 License
Licensed under the MIT License. See LICENSE for details.