Download the PHP package echo-fusion/databasemanager without Composer

On this page you can find all versions of the php package echo-fusion/databasemanager. 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 databasemanager

DatabaseManager

CI Packagist PHP

DatabaseManager is a small, readable database layer for the EchoFusion framework. It is built to be replaced: your code talks to a tiny contract, and the implementation behind it can be our PDO connection, Doctrine DBAL, or anything else you write, chosen in configuration.

It is also meant to show what happens behind the scenes: the whole package is a few hundred lines you can read in an afternoon.

Part of EchoFusion, a modular PHP framework built from small packages.

Installation

Requirements

Quick start

The contract

EchoFusion\Contracts\DatabaseManager\ConnectionInterface:

Method
fetchAll($sql, $params) every row, as associative arrays
fetchOne($sql, $params) the first row, or null
fetchValue($sql, $params) first column of the first row, or null
execute($sql, $params) run INSERT/UPDATE/DELETE/DDL, returns affected rows
lastInsertId($name) id of the last insert
transactional($callback) commit on success, roll back and re-throw on error
beginTransaction(), commit(), rollBack(), inTransaction() manual control

DatabaseManagerInterface adds connection(?string $name), has() and getDefaultConnectionName().

Parameters

Transactions

Transactions nest. The outermost one is a real transaction; inner ones are savepoints, so an inner failure that you catch rolls back only the inner part:

Errors

A failed statement throws EchoFusion\DatabaseManager\Exceptions\QueryException, which carries the SQL (getSql()) and the original exception, but never the bound values (they may be secrets). All exceptions extend DatabaseException.

Query builder

A small fluent builder that works on any ConnectionInterface, so it keeps working if you swap PDO for Doctrine.

Safety built in:

Configuration

Extra PDO attributes go in 'options' => [...]; use 'dsn' => '...' instead of the individual parts when you need an exact DSN. PDO is created with exceptions on, associative fetch mode and real prepared statements. SQLite connections enforce FOREIGN KEY constraints (including ON DELETE CASCADE), which SQLite itself leaves off by default; set 'foreign_keys' => false on a connection to turn that off.

Replacing the implementation

With Doctrine DBAL

Everything written against ConnectionInterface (including the query builder) works the same. The test suite proves it: one shared set of behaviour tests runs against both PdoConnection and DoctrineConnection.

With any other ORM or library

Implement ConnectionInterface (about ten small methods) in a class that takes the connection definition array, and reference it with 'class'. Run the shared behaviour tests (tests/ConnectionContractTestCase.php) against it to check you kept the contract. For example, an adapter around Eloquent's or Cycle's connection can forward fetchAll, execute and the transaction methods one to one.

Behind the scenes

Service provider

EchoFusion\DatabaseManager\Providers\DatabaseManagerProvider registers DatabaseManagerInterface and ConnectionInterface (the default connection) in a container, and configures the manager from the database section of your configuration on boot().

Testing

Credits

License

The MIT License (MIT). Please see LICENSE for more information.


All versions of databasemanager with dependencies

PHP Build Version
Package Version
Requires php Version ~8.1.0 || ~8.2.0 || ~8.3.0
ext-pdo Version *
echo-fusion/contracts Version ^1.7 || ^2.0
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 echo-fusion/databasemanager contains the following files

Loading the files please wait ...