{"id":17134358,"url":"https://github.com/brianium/driven","last_synced_at":"2025-04-13T08:55:06.412Z","repository":{"id":5845826,"uuid":"7062294","full_name":"brianium/driven","owner":"brianium","description":"A console app for creating testable domain driven PHP applications","archived":false,"fork":false,"pushed_at":"2014-03-16T05:15:46.000Z","size":1071,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T22:46:52.074Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brianium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-08T00:37:38.000Z","updated_at":"2016-03-17T20:39:06.000Z","dependencies_parsed_at":"2022-08-31T17:30:50.609Z","dependency_job_id":null,"html_url":"https://github.com/brianium/driven","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianium%2Fdriven","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianium%2Fdriven/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianium%2Fdriven/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianium%2Fdriven/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brianium","download_url":"https://codeload.github.com/brianium/driven/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688544,"owners_count":21145763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T19:44:42.105Z","updated_at":"2025-04-13T08:55:06.389Z","avatar_url":"https://github.com/brianium.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Driven\n======\nDriven is a command line tool for generating a PHP project skeleton\nthat is ready for TDD and DDD(domain driven design).\n\nDirectory Structure\n-------------------\nDriven will create a directory structure that nicely supports a layered architecture.\n\n```bash\n├── bin\n|   └── doctrine\n├── functional\n|   └── Driven\n├── it\n|   └── Driven\n|       ├── Infrastructure\n|       |   └── Persistence\n|       |       └── Doctrine\n|       |           ├── Repositories\n|       |           ├── DoctrineTest.php\n|       |           └── classes.txt\n|       ├── datasets\n|       └── DbTest.php\n├── src\n|   └── Driven\n|       ├── Domain\n|       |   ├── Model\n|       |   |   ├── Repository.php\n|       |   |   └── Entity.php\n|       |   └── Service\n|       └── Infrastructure\n|           └── Persistence\n|               └── Doctrine\n|                   ├── Repositories\n|                   |   └── RepositoryBase.php\n|                   ├── mappings\n|                   ├── proxies\n|                   ├── ConfigurationFactory.php\n|                   ├── EntityManagerFactory.php\n|                   ├── UnitOfWork.php\n|                   └── doctrine.cfg.json\n├── test\n|   ├── Driven\n|   |   ├── Domain\n|   |   |   ├── Model\n|   |   |   └── Service\n|   |   └── TestBase.php\n|   ├── fixtures\n|   └── bootstrap.php\n├── composer.json\n└── phpunit.xml.dist\n```\n\nWhere `Driven` would be replaced with your supplied namespace/vendor dir.\n\ncomposer.json\n-------------\nDriven comes with a composer.json file that includes the following dependencies: phpunit, phpunit/dbunit, and doctrine/orm. \nThe composer.json file also includes autoloader configurations for all source and test directories.\n\nTesting Classes\n---------------\n### TestBase.php ###\nA 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.\n\n### DbTest.php ###\nA base test case that extends PHPUnit's Database_TestCase extension. Contains all the behavior available in TestBase.php.\n\nIt takes advantage of PDO, and the dsn can be configured on a per test basis by overriding the default dsn:\n\n```php\nprotected $dsn = \"pgsql:host=%s;dbname=%s;user=%s;password=%s\";\n```\n\nAdditionally you can override the default schema name by overriding the schema property in tests:\n\n```php\nprotected $schema = \":dbtest:\";\n```\n\nBy 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:\n\n```php\nprotected $truncates = false;\n```\n\nIn 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`\n\n```php\npublic function getDataSet()\n{\n    return $this-\u003edataset('dummy-data.xml');\n}\n```\nFor more information on using the PHPUnit database extension, take a look [here.](http://www.phpunit.de/manual/current/en/database.html)\n\n### DoctrineTest.php ###\nThis 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.\n\n```php\nprotected $classes = array('Driven\\\\Domain\\\\Model\\\\Entity\\\\Entity');\n```\n\nThe 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:\n\n```bash\nClass1,\nClass2,\nClass3\n```\n\nIf the corresponding mapping files exist in the `mappings` directory, the schema for the given entities will be torn down and created before each test.\n\nConfigurations are read from doctrine.cfg.json, so make sure you set the proper environment variable before running PHPUnit.\n\n`ENV=development vendor/bin/phpunit it`\n\nAll test suites and the bootstrap file that loads the composer autoloader are referenced in the phpunit.xml.dist file.\n\nPersistence Classes\n-------------------\nAll 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)\n\n### mappings ###\nThis directory stores the xml mappings used with doctrine. It comes with a sample file to demonstrate conventions.\n\n### proxies ###\nThis is where doctrine will look for proxy classes. These should be generated using the doctrine console.\n\n### ConfigurationFactory.php ###\nThis class is used to generate configurations for doctrine based on the ENV environment variable (development or production).\n\n### EntityManagerFactory.php ###\nUsed for creating or getting a singleton EntityManager. The workhorse for the packaged UnitOfWork and Repository.\n\n### RepositoryBase.php ###\nA 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:\n\n```php\nclass MyEntityRepository extends RepositoryBase\n{\n    protected $type = 'Driven\\\\Domain\\\\Model\\\\MyEntity\\\\MyEntity';\n}\n```\n\n### UnitOfWork.php ###\nA unit of work for transactions to take place within. Contains your standard begin, commit, and rollback methods.\n\n### doctrine.cfg.json ###\nA json file for configuring credentials for development and production.\n\n### Packaged doctrine console ###\nA 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`.\n\nUsage\n-----\n![Driven Usage](https://raw.github.com/brianium/driven/master/driven-usage.png \"Driven Console Usage\")\n\nDriven 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`.\n\nIf you have a composer.phar , you can use it with driven like so:\n\n`driven -c \"php composer.phar\" MyProject`\n\nInstallation\n------------\n\n###Composer###\nDriven can be installed via composer. Just add the following to your composer.json file:\n```js\n\"require\": {\n    \"brianium/driven\": \"dev-master\"\n}\n```\nThen run `php composer.phar install`\n\nYou can also clone the repository directly from github.\n\nAfter installation it may be helpful to setup a symbolic link so you have access to driven globally.\n\n```bash\nsudo ln -s /path/to/driven/bin/driven /usr/bin/driven\n```\n\n###Build a phar###\nA phar can be created by running `php package.php` from the project root. This will create `build/driven.phar`.\n\nIf you receive an error that looks like:\n\n    creating archive \"build/driven.phar\" disabled by INI setting\n\nThis can be fixed by setting the following in your php.ini:\n\n    ; http://php.net/phar.readonly\n    phar.readonly = Off","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrianium%2Fdriven","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrianium%2Fdriven","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrianium%2Fdriven/lists"}