Download the PHP package fishyboat21/extendorm without Composer
On this page you can find all versions of the php package fishyboat21/extendorm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fishyboat21/extendorm
More information about fishyboat21/extendorm
Files in fishyboat21/extendorm
Package extendorm
Short Description Simple Lightweight CRUD ORM for PHP 8.4+
License GPL-3.0-or-later
Homepage https://github.com/FishyBoat21/ExtendOrm
Informations about the package extendorm
ExtendOrm
📖 Table of Contents
- About
- Features
- Requirements
- Database Compatibility
- Installation
- Quick Start
- Documentation
- Database Connection
- Defining Models
- Attributes
- Relationships
- CRUD Operations
- Query Builder
- Transactions
- Examples
- API Reference
- Contributing
- License
📌 About
ExtendOrm is a lightweight, easy-to-use Object-Relational Mapping (ORM) library for PHP 8.4+. It provides a simple yet powerful way to interact with your database using PHP objects, with support for relationships, query building, and transactions.
Perfect for developers who want ORM functionality without the complexity and overhead of heavier solutions like Doctrine or Eloquent.
✨ Features
- 🚀 Lightweight & Fast - Minimal overhead, no bloat
- 🔧 PHP 8.4+ Attributes - Clean, modern syntax for model definitions
- 🔗 Relationships - HasOne, HasMany, BelongsTo support
- 📝 CRUD Operations - Simple save, find, update, delete methods
- 🔍 Query Builder - Fluent interface for complex queries
- 🔒 Transactions - Automatic rollback on errors
- 📦 Pagination - Built-in support for paginated results
- 🎯 Type-Safe - Leverages PHP's type system
- 💾 PDO-Based - Works with MySQL, PostgreSQL, SQLite, and more
📋 Requirements
- PHP 8.4 or higher
- PDO extension enabled
- Database: MySQL or any PDO-compatible database
⚠️ Important Note: For databases other than MySQL (PostgreSQL, SQLite, etc.), you may need to modify the
QueryBuilderto handle database-specific SQL syntax (e.g.,LIMIT/OFFSETsyntax, identifier quoting, date functions, etc.)
🗄️ Database Compatibility
| Database | Status | Notes |
|---|---|---|
| MySQL | ✅ Fully Supported | Tested and recommended |
| MariaDB | ✅ Fully Supported | Compatible with MySQL |
| PostgreSQL | ⚠️ Partial Support | May require LIMIT/OFFSET syntax changes |
| SQLite | ⚠️ Partial Support | May require quote identifier changes |
| SQL Server | ❌ Not Tested | Unconfirmed compatibility |
| Oracle | ❌ Not Tested | Unconfirmed compatibility |
Known MySQL-Specific Syntax
The QueryBuilder currently uses MySQL syntax for the following:
For Other Databases
If you're using PostgreSQL, SQLite, or another database, you may need to adjust:
-
LIMIT/OFFSET Syntax
-
Identifier Quoting
- Auto-increment Primary Keys
📦 Installation
Via Composer (Recommended)
Manual Installation
-
Clone the repository:
-
Include the autoloader in your project:
- Or manually load the classes:
⚡ Quick Start
📚 Documentation
Database Connection
Initialize the database connection using the singleton Database class:
Defining Models
Extend the abstract Model class and use PHP attributes to map your database tables:
Attributes
| Attribute | Description | Example |
|---|---|---|
#[Table('name')] |
Defines the database table name | #[Table('users')] |
#[Column('field')] |
Maps property to database column | #[Column('user_name')] |
#[PrimaryKey] |
Marks the primary key field | #[PrimaryKey] #[Column('id')] |
#[Relation(...)] |
Defines relationships | See below |
Relationships
ExtendOrm supports three relationship types using the #[Relation] attribute.
RelationType Enum
HasOne Relationship
A user has one profile:
HasMany Relationship
A user has many posts:
BelongsTo Relationship
A post belongs to a user:
Complete Model with Multiple Relationships
CRUD Operations
Create (Insert)
Read (Find)
Update
Delete
Query Builder
Available Operators
Sorting
Building Complex Criteria
Transactions
Execute multiple operations in a transaction with automatic rollback on error:
💡 Examples
Blog System - Complete Example
Advanced Filtering and Pagination
📖 API Reference
Model Class
| Method | Description | Returns |
|---|---|---|
save() |
Insert or update record based on primary key | self |
delete() |
Delete record from database | void |
FindOne(Criteria $criteria, IQueryBuilder2 $qb) |
Find single record matching criteria | ?static |
FindMany(Criteria $criteria, IQueryBuilder2 $qb) |
Find multiple records matching criteria | array |
Paging(int $limit, int $offset, Criteria $criteria, QueryBuilder2 $qb) |
Get paginated results | array |
GetTableName() |
Get the table name for the model | string |
Database Class
| Method | Description | Returns |
|---|---|---|
Boot(PDO $connection) |
Initialize the ORM with PDO connection | void |
GetInstance() |
Get the singleton database instance | Database |
GetConnection() |
Get the PDO connection | PDO |
Transaction(callable $function) |
Execute operations in a transaction | mixed |
Criteria Class
| Method | Description | Returns |
|---|---|---|
Add(Criterion $criterion) |
Add a where condition | self |
AddSort(Sort $sort) |
Add sorting order | self |
QueryBuilderOperator Enum
| Value | SQL Equivalent |
|---|---|
Equals |
= |
NotEqual |
!= |
LessThan |
< |
MoreThan |
> |
LessThanEquals |
<= |
MoreThanEquals |
>= |
Like |
LIKE |
NotLike |
NOT LIKE |
Is |
IS (for NULL) |
QueryBuilderSortType Enum
| Value | Description |
|---|---|
Ascending |
ORDER BY ... ASC |
Descending |
ORDER BY ... DESC |
🗂️ Project Structure
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
How to Contribute
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Guidelines
- Follow PSR-12 coding standards
- Add tests for new features
- Update documentation as needed
- Keep commits atomic and descriptive
- Note: If adding support for non-MySQL databases, please include appropriate tests and documentation
📄 License
This project is open-sourced software licensed under the MIT License.
🙏 Acknowledgments
- Inspired by Laravel Eloquent and Doctrine ORM
- Built with ❤️ using PHP 8.4+ features (Attributes, Enums, Typed Properties)
- Thanks to all contributors and users!
📞 Support
- Issues: GitHub Issues
- Source: GitHub Repository
- Author: FishyBoat21
All versions of extendorm with dependencies
ext-pdo Version *