Download the PHP package julienlinard/doctrine-php without Composer

On this page you can find all versions of the php package julienlinard/doctrine-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package doctrine-php

Doctrine PHP - Modern ORM for PHP 8+

🇬🇧 Read in English

PHP Version

A modern, lightweight ORM (Object-Relational Mapping) for PHP 8+ inspired by Doctrine ORM. Features Entity Manager, Repository Pattern, Query Builder, and PHP 8 Attributes mapping with automatic optimizations.

✨ Features

🚀 Quick Start

Installation

Requirements: PHP 8.0+ and PDO extension

Basic Usage

📖 Documentation

Table of Contents

  1. Entity Definition
  2. Entity Manager
  3. Repository
  4. Query Builder
  5. Relations
  6. Transactions
  7. Migrations
  8. Performance Features
  9. Query Logging
  10. API Reference

Entity Definition

Entities are defined using PHP 8 attributes:

Supported Column Types


Entity Manager

The Entity Manager is the central component for managing entities.

Basic Operations

Batch Operations

Insert multiple entities efficiently with a single query:

Transactions

Simplified transaction management with automatic rollback:


Repository

Repositories provide convenient methods for querying entities.

Standard Methods

Advanced Queries

Eager Loading (Optimized N+1)

Load relations efficiently with batch loading:

Custom Repository

Create custom repositories with shared MetadataReader:


Query Builder

Build complex SQL queries with a fluent interface:


Relations

OneToMany / ManyToOne

ManyToMany

Note: Automatic indexes are created on foreign key columns for optimal query performance.


Transactions

Automatic Transaction (Recommended)

Manual Transaction


Migrations

Generate and execute database migrations automatically.

Generate Migrations

CLI Commands

The package includes a ready-to-use CLI script:

Configuration

The CLI script automatically detects configuration from:

  1. Environment variable DOCTRINE_CONFIG (path to PHP file)
  2. config/database.php (from current directory)
  3. ../config/database.php (from current directory)
  4. Environment variables DB_HOST, DB_NAME, DB_USER, DB_PASSWORD

Example config/database.php:

Migration Rollback

Migrations can be rolled back using the CLI:

The system supports:


Performance Features

Query Cache

Cache query results to improve performance:

Batch Operations

Insert multiple entities efficiently:

N+1 Query Optimization

Eager loading with batch loading prevents N+1 queries:

Automatic Indexes

Foreign key columns automatically get indexes for optimal join performance.


Query Logging

Log all SQL queries for debugging and performance analysis:


API Reference

EntityManager Methods

Method Description
persist(object $entity): void Mark entity for persistence
persistBatch(array $entities): void Mark multiple entities for batch insert
flush(): void Execute pending operations
remove(object $entity): void Mark entity for deletion
find(string $entityClass, int\|string $id): ?object Find entity by ID
getRepository(string $entityClass): EntityRepository Get entity repository
createRepository(string $repositoryClass, string $entityClass): EntityRepository Create custom repository
transaction(callable $callback): mixed Execute in transaction with auto rollback
beginTransaction(): void Start transaction
commit(): void Commit transaction
rollback(): void Rollback transaction
enableQueryLog(bool $enabled, ?string $logFile, bool $logToConsole): QueryLoggerInterface Enable query logging
disableQueryLog(): void Disable query logging
getQueryLogger(): ?QueryLoggerInterface Get query logger
generateMigration(string $entityClass): string Generate migration SQL
generateMigrations(array $entityClasses): string Generate migrations for multiple entities

EntityRepository Methods

Method Description
find(int\|string $id): ?object Find entity by ID
findOrFail(int\|string $id): object Find entity by ID or throw exception
findAll(bool $useCache, ?int $cacheTtl): array Find all entities
findBy(array $criteria, ?array $orderBy, ?int $limit, ?int $offset, bool $useCache, ?int $cacheTtl): array Find entities by criteria
findOneBy(array $criteria): ?object Find one entity by criteria
findOneByOrFail(array $criteria): object Find one entity or throw exception
findAllWith(array $relations): array Find all with eager-loaded relations (optimized)

🎯 Best Practices

Performance

  1. Use batch operations for multiple inserts:

  2. Use eager loading to avoid N+1 queries:

  3. Enable query cache for frequently accessed data:

  4. Use transactions for multiple operations:

Code Quality

  1. Use findOrFail() instead of checking for null:

  2. Use custom repositories for complex queries:

  3. Enable query logging during development:

🔗 Integration Examples

With Symfony/Laravel-style Framework


📝 License

MIT License - See the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

💝 Support

If this package is useful to you, consider becoming a sponsor to support development.


Developed with ❤️ by Julien Linard


All versions of doctrine-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-pdo Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package julienlinard/doctrine-php contains the following files

Loading the files please wait ...