{"id":19326041,"url":"https://github.com/linkorb/haigha","last_synced_at":"2025-04-24T04:47:56.515Z","repository":{"id":27828840,"uuid":"31318641","full_name":"linkorb/haigha","owner":"linkorb","description":"Alice fixtures for database tables","archived":false,"fork":false,"pushed_at":"2024-05-16T11:25:39.000Z","size":46,"stargazers_count":24,"open_issues_count":1,"forks_count":8,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-30T07:04:12.406Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linkorb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-25T14:56:53.000Z","updated_at":"2024-05-16T11:25:43.000Z","dependencies_parsed_at":"2024-06-18T22:33:59.722Z","dependency_job_id":"37ccd325-3675-4575-9233-96f7e2535e2f","html_url":"https://github.com/linkorb/haigha","commit_stats":{"total_commits":33,"total_committers":6,"mean_commits":5.5,"dds":0.3939393939393939,"last_synced_commit":"5ca5517eb5b5ac5450038b9d4916c449760d27b0"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkorb%2Fhaigha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkorb%2Fhaigha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkorb%2Fhaigha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkorb%2Fhaigha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linkorb","download_url":"https://codeload.github.com/linkorb/haigha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248850922,"owners_count":21171830,"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-11-10T02:12:17.317Z","updated_at":"2025-04-24T04:47:56.495Z","avatar_url":"https://github.com/linkorb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!TIP]\n\u003e Haigha has been superseeded by the brand new [Hatter](https://github.com/linkorb/haigha) - similar features, still application independant, but no longer trying to use Alice in a way that it wasn't designed for. \n\n# Haigha: Alice fixtures for tables\n\n\u003cimg src=\"http://3.bp.blogspot.com/-9_Jt3gdf6fU/T-28_RUpoFI/AAAAAAAACBg/xgAxK-2fgLY/s1600/MarchHare.jpg\" style=\"width: 100%\" /\u003e\n\n[Alice](https://github.com/nelmio/alice) is an *awesome* database fixtures library.\nIt works with Doctrine out-of-the-box, but if you don't use the Doctrine ORM, you'll need custom persisters...\n\nThis is where **Haigha** comes in:\n\n\u003e *Haigha lets you use Alice directly with database tables!*\n\n## Features\n\n* Supports all standard Alice functionality (ranges, optional data, references, inheritence, etc)\n* Supports Faker data providers\n* Supports any PDO connection\n* No need to write classes, directly persist from yml to your sql database\n\n## Example fixture file\n\nHaigha uses Alice to load fixture files, so the format is identical ([Details](https://github.com/nelmio/alice)). The only thing to keep in mind is that you use tablenames instead of classnames. Prefix your tablenames with `table.`. For example, if your tablename is called `user`, you use it like this:\n\n```yaml\ntable.group:\n  group_random_users:\n    id: 1 # This is important for version ~2.0\n    name: Random users\n\ntable.user:\n  random_user{0..9}:\n    group_id: @group_random_users\n    username: \u003cuserName()\u003e\n    firstname: \u003cfirstName()\u003e\n    lastname: \u003clastName()\u003e\n    password: \u003cpassword()\u003e\n    email: \u003cemail()\u003e\n```\n\n## How to use Haigha in your application\n\nSimply add the following to your `require` or `require-dev` section in your [composer.json](http://getcomposer.org) and run `composer update`:\n\n```json\n\"require\": {\n  \"linkorb/haigha\": \"^2.0\"\n}\n```\n\nYou can now use Haigha in your applications, or use the included command-line tool to load fixtures into your database:\n\n## Command-line usage\n\nThe haigha command-line tool knows one sub-command: `fixtures:load`.\n\nThe first argument is the filename of your fixture definition (yaml).\n\nThe second argument is the (optional) database url. If no database url is specified, haigha used your `PDO` environment variable instead.\n\n### Database URL\n\nA full URL containing username, password, hostname and dbname. For example:\n\n```\n./vendor/bin/haigha fixtures:load examples/random_users.yml mysql://username:password@hostname/dbname\n```\n\n### Just a dbname\n\nIn this case [linkorb/database-manager](https://github.com/linkorb/database-manager) is used for loading database connection details (server, username, password, etc) from .conf files (read project readme for more details).\n\nIn a nutshell - you must have a `database_name.conf` file at `/share/config/database/` as described at [database-manager's documentation](https://github.com/linkorb/database-manager#database-configuration-files).\n\n```bash\n./vendor/bin/haigha fixtures:load examples/random_users.yml dbname\n```\n\n## Library usage:\n\nYou can use Haigha in your own application like this:\n\n```php\n// Instantiate a new Alice loader\n$loader = new Nelmio\\Alice\\Fixtures\\Loader();\n\n// Add the Haigha instantiator\n$instantiator = new Haigha\\TableRecordInstantiator();\n$loader-\u003eaddInstantiator($instantiator);\n\n// Load (Haigha) objects from a Alice yml file\n$objects = $loader-\u003eload('examples/random_users.yml');\n\n// Instantiate the Haigha PDO persister, and pass a PDO connection\n$persister = new PdoPersister($pdo);\n\n// Persist the Haigha objects on the PDO connection\n$persister-\u003epersist($objects);\n```\n\n## Test\n\nCustomize `phpunit.xml`:\n\n```\ncp phpunit.xml.dist phpunit.xml\n```\n\nRun:\n\n```\nvendor/bin/phpunit\n```\n\n## License\n\nMIT (see [LICENSE.md](LICENSE.md))\n\n## Brought to you by the LinkORB Engineering team\n\n\u003cimg src=\"http://www.linkorb.com/d/meta/tier1/images/linkorbengineering-logo.png\" width=\"200px\" /\u003e\u003cbr /\u003e\nCheck out our other projects at [linkorb.com/engineering](http://www.linkorb.com/engineering).\n\nBtw, we're hiring!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkorb%2Fhaigha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkorb%2Fhaigha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkorb%2Fhaigha/lists"}