Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Database Laravel Package

nette/database

Nette Database is a lightweight yet powerful PHP database layer with an intuitive query builder, safe parameter binding, and support for MySQL, PostgreSQL, SQLite, MS SQL, and Oracle. Clean API plus optional ORM-like conveniences make queries simple and secure.

View on GitHub
Deep Wiki
Context7

Nette Database is a lightweight database abstraction layer for PHP that provides a safe, intuitive API for querying databases without repetitive boilerplate. It includes a powerful SQL builder, prepared statements, and a query preprocessor that handles parameter binding and platform-specific SQL syntax.

Built for the Nette Framework but usable standalone, it supports MySQL, PostgreSQL, SQLite, MS SQL, and Oracle, offers transactions, an Explorer API for table/row access, and clean error handling for readable, secure, maintainable database code.

  • Fluent SQL builder with parameter binding
  • Query preprocessor for portable SQL
  • Transactions and connection management
  • Explorer API for tables and rows
  • Support for major database drivers
Frequently asked questions about Database
Is nette/database compatible with Laravel?
Nette Database is framework-agnostic and can run inside a Laravel app, but it is not natively integrated with Laravel. There is no service provider, facade, config mapping, or Eloquent interop, so you must write your own glue. It sits beside Illuminate\Database rather than replacing or plugging into it.
How do I install nette/database in a Laravel project?
Install it with Composer using composer require nette/database. You then need to build a Laravel service provider that maps your database connection settings into a Nette\Database\Connection singleton. Budget roughly a day for that integration work and plan to own it, because no first-party Laravel package exists.
Can I use nette/database and Eloquent together in the same Laravel app?
You can, but they are separate data-access layers with separate query logs, schema truths, and transaction APIs. Eloquent models and Nette ActiveRow objects cannot be mixed, so any table touched by nette/database should be behind a repository boundary. Without discipline the codebase can fork into two permanent DALs.
Does nette/database provide a Laravel service provider or DB facade integration?
No. nette/database has no Laravel integration surface at all: no service provider, no facade, no config mapping, and no DB::listen or Telescope hooks. Its only first-party DI glue is DatabaseExtension, which targets nette/di and is irrelevant in Laravel. Any Laravel wiring is bespoke code you maintain.
Which Laravel and PHP versions does nette/database support?
There is no Laravel version matrix because nette/database does not integrate with Laravel directly; it is a standalone PHP library built around PDO. Check the package's own composer.json for its PHP requirements, and test against your app's Laravel and PHP versions yourself. The bigger compatibility concern is the in-flight v4 release, which removes getPdo() and getDsn().
How do transactions behave when nette/database shares a PDO with Laravel?
In nette/database 3.x you can share Laravel's PDO handle via the constructor, but Laravel and Nette each implement nested transactions with independent savepoint counters. A Laravel DB::transaction() wrapping a Nette transaction(), or the reverse, can produce mismatched savepoint depth and silent partial commits. Test nesting carefully; Nette only added nesting support in 3.1.2, so this path is thinly exercised.
What are the main benefits of nette/database over Eloquent?
The differentiating features are narrow but real: an FK-graph-aware Explorer and ActiveRow that infer relationships from live schema, so $row->related('comments') works without model definitions. It also provides unified schema reflection metadata across drivers and typed failures such as DeadlockException, LockTimeoutException, CheckConstraintViolationException, and ConnectionLostException. Those typed exceptions are materially better than Laravel's QueryException plus driver-code string matching for surgical retry logic.
Is nette/database actively maintained and production-ready?
The technical assessment calls it a well-maintained, genuinely capable PHP data-access layer, so quality is not the concern. Adoption inside Laravel is thin: the assessment score is 44.4 with zero reported dependents, which signals a solid library with a thin Laravel adoption story. For Laravel teams, adopt it opportunistically as a bounded, read-heavy or reporting-side tool, not as a platform decision.
What license does nette/database use, and is that a risk?
GitHub reports NOASSERTION for the license, so automated detection failed even though Nette is normally BSD-3-Clause. Legal should confirm the license before you make it a production dependency. Until that is resolved, treat it as a high-severity blocking risk.
What should I watch out for before adopting nette/database in a Laravel codebase?
The main risks are a dual DAL, transaction nesting mismatches that can cause silent data corruption, and data-shape differences from Eloquent casts such as zero-dates becoming NULL and TINYINT(1) becoming bool. Version 4.0.0-RC1 is in flight and removes getPdo() and getDsn(), drops IRow/IRowContainer, and changes date handling, so adopting 3.2.x now means a later migration. Schema-derived relationships also couple you to live schema drift.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
tobya/saloonfire
kjmtrue/laravel-debugbar
hexincorp/debugbar
razorbacks/laravel-shibboleth
adilazhari/laravel-idempotency
mamitech/laravel-slow-query-log
mamitech/laravel-http-logger
medeirosrafael/docxmustache
webdevlabs/phreak
vis/log-envelope
digitickets/lalit
acacha/names
scool/foundation
frankkessler/guzzle-oauth2-middleware
delatbabel/site-config
delatbabel/applog
eusonlito/laravel-gettext
henzeb/housepedia-intelligence-laravel
aliqsm/laravel-authkit
itsjustvita/laravel-wp-migrator