PHPackages                             patrick-barreto/data-base - 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. patrick-barreto/data-base

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

patrick-barreto/data-base
=========================

Basic ORM to manipulate database and make a CRUD at model class very easy

v1.0.1(1y ago)1178GPL-3.0-or-laterPHPPHP &gt;=7.0CI passing

Since Jan 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/PatrickBarreto/DataBase)[ Packagist](https://packagist.org/packages/patrick-barreto/data-base)[ RSS](/packages/patrick-barreto-data-base/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (9)Used By (0)

About Project
=============

[](#about-project)

If you dont't have a php environment with a database, you can use this docker environment:

The next step of this code is:

- Implement the essentials DDL Commands (CREATE, DROP, TRUNCATE, ALTER)

If you have an idea or pull request to make, do it. Ideas are very welcome.

How to Install
==============

[](#how-to-install)

```
composer require patrick-barreto/data-base
```

.env
====

[](#env)

You need to fill your environments variables. If you want make it easy use

```
DotEnv\DotEnv::fill(PATH_.ENV_FILE);
```

How to Use
==========

[](#how-to-use)

### Repository

[](#repository)

```
//Model
class Users extends DataBaseCorrespondence {
    private static string $table = 'users';

    public static function getTable(){
        return self::$table;
    }

    public function getProperty($property){
        return $this->$property;
    }
}

//Repository
class UserRepository extends Repository{

    public function findUsers() {
        return $this->select()->setFields(['id', 'name', 'email', 'phone'])
                              ->fetchObject(false, $this->getDtoPath());
    }
}

//Using in Controller for exemple
class Users {
  use UserRepository;
  use Users;

  public function findUsers() {
    //This will be and instance of UserRepository, class responsable to provide methods of User Object.
    $usersRepository = new UserRepository(new Users);

    //This will return an instance of Users.
    $users = $usersRepository->findUsers();

  }
}
```

### Use the Crud Instance

[](#use-the-crud-instance)

```
