PHPackages                             brianium/driven - 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. [Framework](/categories/framework)
4. /
5. brianium/driven

ActiveLibrary[Framework](/categories/framework)

brianium/driven
===============

Easy creation of domain driven projects for PHP

98PHP

Since Mar 16Pushed 12y ago2 watchersCompare

[ Source](https://github.com/brianium/driven)[ Packagist](https://packagist.org/packages/brianium/driven)[ RSS](/packages/brianium-driven/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Driven
======

[](#driven)

Driven is a command line tool for generating a PHP project skeleton that is ready for TDD and DDD(domain driven design).

Directory Structure
-------------------

[](#directory-structure)

Driven will create a directory structure that nicely supports a layered architecture.

```
├── bin
|   └── doctrine
├── functional
|   └── Driven
├── it
|   └── Driven
|       ├── Infrastructure
|       |   └── Persistence
|       |       └── Doctrine
|       |           ├── Repositories
|       |           ├── DoctrineTest.php
|       |           └── classes.txt
|       ├── datasets
|       └── DbTest.php
├── src
|   └── Driven
|       ├── Domain
|       |   ├── Model
|       |   |   ├── Repository.php
|       |   |   └── Entity.php
|       |   └── Service
|       └── Infrastructure
|           └── Persistence
|               └── Doctrine
|                   ├── Repositories
|                   |   └── RepositoryBase.php
|                   ├── mappings
|                   ├── proxies
|                   ├── ConfigurationFactory.php
|                   ├── EntityManagerFactory.php
|                   ├── UnitOfWork.php
|                   └── doctrine.cfg.json
├── test
|   ├── Driven
|   |   ├── Domain
|   |   |   ├── Model
|   |   |   └── Service
|   |   └── TestBase.php
|   ├── fixtures
|   └── bootstrap.php
├── composer.json
└── phpunit.xml.dist
```

Where `Driven` would be replaced with your supplied namespace/vendor dir.

composer.json
-------------

[](#composerjson)

Driven comes with a composer.json file that includes the following dependencies: phpunit, phpunit/dbunit, and doctrine/orm. The composer.json file also includes autoloader configurations for all source and test directories.

Testing Classes
---------------

[](#testing-classes)

### TestBase.php

[](#testbasephp)

A base test case for unit testing. It contains helpers for loading fixtures from the `fixtures` directory, and has methods for getting and setting private/protected properties.

### DbTest.php

[](#dbtestphp)

A base test case that extends PHPUnit's Database\_TestCase extension. Contains all the behavior available in TestBase.php.

It takes advantage of PDO, and the dsn can be configured on a per test basis by overriding the default dsn:

```
protected $dsn = "pgsql:host=%s;dbname=%s;user=%s;password=%s";
```

Additionally you can override the default schema name by overriding the schema property in tests:

```
protected $schema = ":dbtest:";
```

By default, driven assumes PostgreSQL. This database supports the `TRUNCATES` operation for removing rows. The DbTest takes advantage of this. If you use a database that does not support this, then override the `$truncates` property:

```
protected $truncates = false;
```

In addition, there is a helper that can be called to load a dataset from xml into the database using the PHPUnit provided method `getDataSet`. It will look for these datasets in the datasets directory contained in the integration test suite: `it`

```
public function getDataSet()
{
    return $this->dataset('dummy-data.xml');
}
```

For more information on using the PHPUnit database extension, take a look [here.](http://www.phpunit.de/manual/current/en/database.html)

### DoctrineTest.php

[](#doctrinetestphp)

This base test case extends DbTest, and takes advantage of some Doctrine2 tools to make testing easier. It makes use of the UnitOfWork to test a typical work flow in a web application. It will create a schema for testing based on the list of supplied classes. Entity classes are supplied via the $classes property.

```
protected $classes = array('Driven\\Domain\\Model\\Entity\\Entity');
```

The classes.txt file exists if you prefer to manage that list of classes in a separate file. It follows a format of one class per line, with each line ending in a comma:

```
Class1,
Class2,
Class3
```

If the corresponding mapping files exist in the `mappings` directory, the schema for the given entities will be torn down and created before each test.

Configurations are read from doctrine.cfg.json, so make sure you set the proper environment variable before running PHPUnit.

`ENV=development vendor/bin/phpunit it`

All test suites and the bootstrap file that loads the composer autoloader are referenced in the phpunit.xml.dist file.

Persistence Classes
-------------------

[](#persistence-classes)

All persistence related classes are kept in the `Doctrine` directory. The components have been tested and used as part of the project located [here.](https://github.com/brianium/php-classic-blog)

### mappings

[](#mappings)

This directory stores the xml mappings used with doctrine. It comes with a sample file to demonstrate conventions.

### proxies

[](#proxies)

This is where doctrine will look for proxy classes. These should be generated using the doctrine console.

### ConfigurationFactory.php

[](#configurationfactoryphp)

This class is used to generate configurations for doctrine based on the ENV environment variable (development or production).

### EntityManagerFactory.php

[](#entitymanagerfactoryphp)

Used for creating or getting a singleton EntityManager. The workhorse for the packaged UnitOfWork and Repository.

### RepositoryBase.php

[](#repositorybasephp)

A handy base for all entity repositories to extend. Includes methods to fetch all entities, fetch a single entity by id, fetch multiple entities by condition, persist an entity, and delete an entity. The only requirement is that subclasses specify the entity type they are persisting:

```
class MyEntityRepository extends RepositoryBase
{
    protected $type = 'Driven\\Domain\\Model\\MyEntity\\MyEntity';
}
```

### UnitOfWork.php

[](#unitofworkphp)

A unit of work for transactions to take place within. Contains your standard begin, commit, and rollback methods.

### doctrine.cfg.json

[](#doctrinecfgjson)

A json file for configuring credentials for development and production.

### Packaged doctrine console

[](#packaged-doctrine-console)

A fully functional doctrine console comes packaged in the `bin` directory. Some tweaking may be required depending on your OS to make it executable. Nix users can simply do the following `chmod +x doctrine`.

Usage
-----

[](#usage)

[![Driven Usage](https://camo.githubusercontent.com/a3294024b29db380e14806a22dbbd0faaa427fe7be53ff802c03337680142ce7/68747470733a2f2f7261772e6769746875622e636f6d2f627269616e69756d2f64726976656e2f6d61737465722f64726976656e2d75736167652e706e67 "Driven Console Usage")](https://camo.githubusercontent.com/a3294024b29db380e14806a22dbbd0faaa427fe7be53ff802c03337680142ce7/68747470733a2f2f7261772e6769746875622e636f6d2f627269616e69756d2f64726976656e2f6d61737465722f64726976656e2d75736167652e706e67)

Driven will create a project structure inside the current working directory. The only available option is to specify the composer binary. By default composer is assumed to be globally installed as `composer`.

If you have a composer.phar , you can use it with driven like so:

`driven -c "php composer.phar" MyProject`

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

[](#installation)

\###Composer### Driven can be installed via composer. Just add the following to your composer.json file:

```
"require": {
    "brianium/driven": "dev-master"
}
```

Then run `php composer.phar install`

You can also clone the repository directly from github.

After installation it may be helpful to setup a symbolic link so you have access to driven globally.

```
sudo ln -s /path/to/driven/bin/driven /usr/bin/driven
```

\###Build a phar### A phar can be created by running `php package.php` from the project root. This will create `build/driven.phar`.

If you receive an error that looks like:

```
creating archive "build/driven.phar" disabled by INI setting

```

This can be fixed by setting the following in your php.ini:

```
; http://php.net/phar.readonly
phar.readonly = Off

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f71e23eec19a24f64f37c622e76e725c9a580f83ff40c411da9bad97e0a49089?d=identicon)[brianium](/maintainers/brianium)

---

Top Contributors

[![brianium](https://avatars.githubusercontent.com/u/636651?v=4)](https://github.com/brianium "brianium (21 commits)")

### Embed Badge

![Health badge](/badges/brianium-driven/health.svg)

```
[![Health](https://phpackages.com/badges/brianium-driven/health.svg)](https://phpackages.com/packages/brianium-driven)
```

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
