Download the PHP package shaik-obydullah/lime-php-framework without Composer
On this page you can find all versions of the php package shaik-obydullah/lime-php-framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shaik-obydullah/lime-php-framework
More information about shaik-obydullah/lime-php-framework
Files in shaik-obydullah/lime-php-framework
Package lime-php-framework
Short Description A lightweight PHP MVC framework
License MIT
Homepage https://github.com/shaik-obydullah/lime-php-framework
Informations about the package lime-php-framework
Lime PHP Framework
A lightweight, minimal PHP MVC framework with routing, database abstraction, migrations, and a simple templating engine. Designed for small to medium web applications.
Packagist
Available on Packagist.
Documentation
- User Guide
Features
- MVC Architecture – Clean separation of concerns with Controllers, Models, and Views
- Simple Router – Define routes with support for URL parameters (
{id}), GET/POST/PUT/DELETE - Database Layer – PDO-based query builder with prepared statements (MySQL)
- Migration System – Run SQL migration files from the command line
- View Engine – Plain PHP templates with data extraction
- Autoloading – PSR-4-like autoloading for
Lime\andApp\namespaces - Environment Config –
.envfile support - CLI Tool –
php limefor running migrations - JSON & Redirect Helpers – Built into the base Controller
Requirements
- PHP 8.1+
- MySQL 5.7+ / MariaDB 10.2+
- Composer (for third-party dependencies)
- Apache mod_rewrite (or nginx equivalent)
Installation
Via Composer (Recommended)
Manual Installation
Copy the contents of this repository into your project root:
2. Install dependencies
3. Configure environment
Copy .env and set your database credentials:
4. Run migrations
5. Serve the application
Point your browser to http://localhost:8000.
Directory Structure
Routing
Define routes in App/Router/web.php:
Available methods
| Method | Description |
|---|---|
Router::get($uri, $handler) |
Register a GET route |
Router::post($uri, $handler) |
Register a POST route |
Router::match($methods, $uri, $handler) |
Register for multiple HTTP methods |
Route handlers follow the format: ControllerName@methodName
URL Parameters
Parameters are defined with curly braces and passed as method arguments:
Controllers
Controllers extend Lime\Controller and are placed in App/Controller/ under the App\Controller namespace.
Base Controller Methods
| Method | Description |
|---|---|
$this->view($path, $data) |
Render a view with data |
$this->redirect($url) |
Redirect to a URL |
$this->json($data, $status) |
Return JSON response |
Views
Views are plain PHP files in App/View/. Data passed from the controller is extracted as variables.
View paths use dots for subdirectories: home/index maps to App/View/home/index.php.
Database
The Lime\Database class provides a singleton PDO connection and helper methods.
Methods
| Method | Returns | Description |
|---|---|---|
Database::connect() |
PDO |
Get the singleton PDO instance |
Database::query($sql, $params) |
PDOStatement |
Execute a prepared query |
Database::fetch($sql, $params) |
?array |
Fetch one row or null |
Database::fetchAll($sql, $params) |
array |
Fetch all rows |
Database::insert($sql, $params) |
int |
Insert and return lastInsertId |
Database::execute($sql, $params) |
int |
Execute and return rowCount |
All queries use prepared statements with automatic parameter binding for security.
Models
Models extend Lime\Model and provide direct database access. They share the same PDO connection.
Model Methods
| Method | Returns | Description |
|---|---|---|
Model::query($sql, $params) |
PDOStatement |
Execute a prepared query |
Model::fetchAll($sql, $params) |
array |
Fetch all rows |
Model::fetchOne($sql, $params) |
?array |
Fetch one row or null |
Model::execute($sql, $params) |
int |
Execute and return lastInsertId |
Migrations
Migration files are SQL files placed in App/Database/Migrations/. They are executed in filename order.
Creating a migration
Create a file like 001_create_users.sql:
Running migrations
Migrations are tracked in a migrations table. Only files that haven't been run yet will execute.
Environment Configuration
The framework loads a .env file from the project root. Variables are available via $_ENV and getenv().
Lines starting with # are treated as comments. The .env file should NOT be committed to version control.
Serving in Production
Apache
The included .htaccess files handle URL rewriting. Ensure mod_rewrite is enabled and AllowOverride All is set for the document root.
Nginx
Architecture Overview
Request Lifecycle
.htaccessrewrites all requests toPublic/index.phpindex.phpblocks direct access to internal directoriesSystem/Bootstrap.phploads environment, registers autoloader, loads routesRouter::dispatch()matches the request URI and method- The matched controller method is called with extracted parameters
- The controller renders a view or returns a JSON response
Namespace Mapping
| Namespace | Directory |
|---|---|
Lime\ |
System/ |
App\ |
App/ |
The autoloader in Bootstrap.php handles PSR-4-style class loading for both namespaces.
Security
- All database queries use PDO prepared statements to prevent SQL injection
- View output should be escaped with
htmlspecialchars() - Direct access to
App/,System/,vendor/, andstorage/is blocked - Root
.htaccessrestricts access to system directories
License
MIT