stdimitrov / orm
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:libary
Requires
- php: ^8.4
README
A lightweight and flexible PHP library that simplifies database interactions by providing a basic custom ORM (Object-Relational Mapping) layer on top of PDO. Designed for developers who want simple, clean, and efficient access to their databases without heavy frameworks.
Requirements
- PHP 8.4 or higher
- PDO extension enabled
Features
- Automatic model generation from existing database tables
- Support InnoDB and MySQL Cluster
- Simple and intuitive CRUD operations
- Read/Write database connection support
- Automatic mapping between
snake_case
(database) andcamelCase
(PHP) - Secure queries using prepared statements
- Lightweight and dependency-free (except PDO)
- PSR-12 compliant coding standards
Installation
- Download a latest package or use Composer:
composer require stdimitrov/orm
- Create environment file
.env
in the root directory of your project:
DB_HOST=localhost DB_NAME=your_database_name DB_USER=your_database_user DB_PASS=your_database_password DB_PORT_RO=3306 # this is port for read connection DB_PORT_RW=3306 # this is port for write connection MODEL_NAMESPACE=App\Models # Namespace for your models
Basic Usage
- Create task for creating models:
$dir = __DIR__ . '/models'; // Directory where the models will be created new \Stdimitrov\Orm\Tasks\CreateModels()->run($dir);
- Create a repository extending current model:
class UsersRepository extends \App\Models\Users { // Add custom methods here }
Contributing
Contributions are welcome!
Please fork the repository, create a feature branch, and submit a pull request.
Follow PSR-12 coding standards and include relevant tests.
License
This project is licensed under the MIT License.
Support
For issues, please open a GitHub Issue or contact [stdimitrov05@gmail.com].