There is no license information available for the latest version (1.0.12) of this package.

1.0.12 2025-04-29 12:06 UTC

This package is auto-updated.

Last update: 2025-04-29 12:35:54 UTC


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) and camelCase (PHP)
  • Secure queries using prepared statements
  • Lightweight and dependency-free (except PDO)
  • PSR-12 compliant coding standards

Installation

  1. Download a latest package or use Composer:
composer require stdimitrov/orm
  1. 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

  1. Create task for creating models:
$dir = __DIR__ . '/models'; // Directory where the models will be created
new \Stdimitrov\Orm\Tasks\CreateModels()->run($dir);
  1. 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].