thephprame / thephprame-core
Core of the phprame framework
Requires
- php: >=8.0.0
- php-di/php-di: ^7.1
README
Core utilities and base classes for the phprame PHP micro-framework.
This package contains the core building blocks used by thephprame applications: base controller and model classes, HTTP request/response wrappers, routing helpers, middleware base, and lightweight helpers for files, cookies, encryption and database access.
Key Features
- Minimal, framework-agnostic helpers for small apps
- Base classes: controllers, models and middleware
- Request/Response and routing support
- Small utility helpers: Files, Cookies, Encryption, Database
Installation
If the package is available via Composer (packagist):
composer require thephprame/thephprame-core
For local development (when using this repo as a local package), add a path repository to your application's composer.json and require the package by name:
"repositories": [ { "type": "path", "url": "../local-packages/thephprhame-core" } ]
Then run composer require thephprame/thephprame-core in your application.
Quick Usage
These examples illustrate common patterns — adapt them to your app structure.
Controllers
Extend the base controller to create action methods used by routes:
class HomeController extends Controller { public function index() { return Response::view('home', ['name' => 'world']); } }
Models
Create models by extending Model for simple DB interactions:
class User extends Model { protected $table = 'users'; } $user = (new User())->find(1);
Routing
Register routes using the Routes helper (see the application's Routes files):
Routes::get('/', [HomeController::class, 'index']); Routes::post('/api/items', [ItemController::class, 'store']);
Request / Response
Use Request to access input and Response to send responses:
$name = Request::input('name', 'guest'); return Response::json(['hello' => $name]);
Utility Classes (brief)
Controller— base controller classModel— base model with simple DB helpersRoutes— route registration helpersRequest/Response— HTTP wrappersMiddleware— base middleware classDatabase/DatabaseHelper— DB connection and helpersEncryption— encryption utilitiesFile/Files— file helpersCookie/Cookies— cookie helpersIException— core exception interface
Contributing
Contributions are welcome. Please open issues or pull requests against the repository. Keep changes focused and include tests/examples where appropriate.
License
The package is distributed under the MIT License. See the composer.json for license metadata.
Authors
See composer.json authors field for package authors.