PHPackages                             peak/database - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. peak/database

ActiveLibrary[Database &amp; ORM](/categories/database)

peak/database
=============

Database generic tooling + Laravel database wrapper + database migration with Phinx

1.0.2(6y ago)0611MITPHPPHP &gt;=7.2

Since Jun 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/peakphp/database)[ Packagist](https://packagist.org/packages/peak/database)[ RSS](/packages/peak-database/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (1)

Peak/Database
=============

[](#peakdatabase)

The purposes of this package are:

- provide generic agnostic database tools for DDD and Clean architecture
- provide database migration with [Phinx migration](https://packagist.org/packages/robmorgan/phinx)
- facilitate the integration of [Laravel Database](https://packagist.org/packages/illuminate/database) in non-laravel project

Installation
------------

[](#installation)

```
 composer require peak/database

```

Laravel Database Usage
----------------------

[](#laravel-database-usage)

```
use Peak\Database\Laravel\DatabaseService;

$config = [
    'driver' => 'mysql',
    'host' => 'localhost',
    'port' => '3306',
    'database' => 'database',
    'username' => 'root',
    'password' => 'root',
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
];

$db = (new DatabaseService())->createConnection($config, 'connectionName');
```

That's it! Check out [Laravel Query Builder](https://laravel.com/docs/5.8/queries) for more info on how to make queries.

Database Migration Usage
------------------------

[](#database-migration-usage)

For database migrations, create a file at the root of your project name `phinx.php`. This file should return an array of Phinx configuration.

```
