{"id":19039621,"url":"https://github.com/windwalker-io/rad-development-bundle","last_synced_at":"2025-06-20T14:37:06.848Z","repository":{"id":57081041,"uuid":"55206755","full_name":"windwalker-io/rad-development-bundle","owner":"windwalker-io","description":"Development Bundle includes Seeders and Sql sync tools.","archived":false,"fork":false,"pushed_at":"2018-11-21T03:27:49.000Z","size":1971,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-21T22:30:47.524Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/windwalker/rad-development-bundle","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/windwalker-io.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":"2016-04-01T05:43:49.000Z","updated_at":"2018-11-21T03:27:51.000Z","dependencies_parsed_at":"2022-08-24T14:58:13.523Z","dependency_job_id":null,"html_url":"https://github.com/windwalker-io/rad-development-bundle","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/windwalker-io/rad-development-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Frad-development-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Frad-development-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Frad-development-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Frad-development-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/windwalker-io","download_url":"https://codeload.github.com/windwalker-io/rad-development-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Frad-development-bundle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260963054,"owners_count":23089540,"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-08T22:17:55.817Z","updated_at":"2025-06-20T14:37:01.836Z","avatar_url":"https://github.com/windwalker-io.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windwalker Joomla RAD Development Bundle\n\nSome helpful command line tools to operate database for development.\n\n## Table of Content\n\n- [Sqlsync](#sql-sync)\n- [Seeder](#seeder)\n\n## Installation via Composer\n\n``` bash\ncd /to/your/joomla\n\ncomposer create-project windwalker/rad-development-bundle libraries/windwalker-bundles/DevelopmentBundle 1.*\n```\n\n## Commands\n\n``` bash\nWindwalker Console - version: 2.1\n------------------------------------------------------------\n\n# system commands ...\n\n  seed         The data seeder help you create fake data.\n    import       Import seeders.\n    clear        Clear seeders.\n\n  sql          SQL sync \u0026 diff tools.\n    backup       Backup sql.\n    col          Column operation\n    export       Export sql.\n    import       Import a sql file.\n    profile      Profiles.\n    restore      Restore to pervious point.\n    table        Model operation.\n```\n\n## SQL Sync\n\nWindwalker Sqlsync is a powerful SQL compare \u0026 diff tools help developers update their SQL schema.\n\n### Why Not Migration Tools?\n\nActually, we are developing a migration tools for Joomla \u0026 Windwalker now, but migration is not so suitable for Joomla CMS, sometimes \nwe will want to sync Joomla articles, modules, extensions and menus to your production server. Migration tools are\nhard to do this. \n\nSo, using Sqlsync tools will help you compare sql schema between your local \u0026 remote machine, simply run `export` in your local,\nand git track all schema YAML files. Then push your files to remote server and run `import`, all schemas will update to remote.\n\n\u003e Currently Sqlsync are weak on column name change, you can use hooks to do this.\n\n### Export \u0026 Import SQL Schema\n\n``` bash\nphp bin/windwalker sql export\n\nphp bin/windwalker sql import\n```\n\nScheam will export to `resources/sqlsync/default/schema.yml`\n\n### Track Tables\n\nTable track information stores in `resources/sqlsync/default/track.yml`\n\nDefault is:\n\n``` yaml\ntable:\n    '#__assets': all\n    '#__associations': all\n    '#__banner_clients': all\n    '#__banner_tracks': all\n    '#__banners': all\n    '#__categories': all\n    '#__contact_details': all\n    '#__content': all\n    '#__content_frontpage': all\n    '#__content_rating': all\n    '#__content_types': all\n    '#__contentitem_tag_map': all\n    '#__core_log_searches': all\n    '#__extensions': all\n    '#__finder_filters': cols\n    '#__finder_links': cols\n    '#__finder_links_terms0': cols\n    '#__finder_links_terms1': cols\n    '#__finder_links_terms2': cols\n    '#__finder_links_terms3': cols\n    '#__finder_links_terms4': cols\n    '#__finder_links_terms5': cols\n    '#__finder_links_terms6': cols\n    '#__finder_links_terms7': cols\n    '#__finder_links_terms8': cols\n    '#__finder_links_terms9': cols\n    '#__finder_links_termsa': cols\n    '#__finder_links_termsb': cols\n    '#__finder_links_termsc': cols\n    '#__finder_links_termsd': cols\n    '#__finder_links_termse': cols\n    '#__finder_links_termsf': cols\n    '#__finder_taxonomy': cols\n    '#__finder_taxonomy_map': cols\n    '#__finder_terms': cols\n    '#__finder_terms_common': all\n    '#__finder_tokens': cols\n    '#__finder_tokens_aggregate': cols\n    '#__finder_types': cols\n    '#__languages': all\n    '#__menu': all\n    '#__menu_types': all\n    '#__messages': all\n    '#__messages_cfg': all\n    '#__modules': all\n    '#__modules_menu': all\n    '#__newsfeeds': all\n    '#__overrider': all\n    '#__postinstall_messages': all\n    '#__redirect_links': all\n    '#__schemas': all\n    '#__session': cols\n    '#__tags': all\n    '#__template_styles': all\n    '#__ucm_base': all\n    '#__ucm_content': all\n    '#__ucm_history': all\n    '#__update_sites': all\n    '#__update_sites_extensions': all\n    '#__updates': cols\n    '#__user_keys': all\n    '#__user_notes': all\n    '#__user_profiles': all\n    '#__user_usergroup_map': all\n    '#__usergroups': all\n    '#__users': all\n    '#__utf8_conversion': all\n    '#__viewlevels': all\n```\n\nThere are 3 track rules:\n\n- `all` - Track all data, always refresh data when import \u0026 export.\n- `cols` - Only track table columns, do not refresh data.\n- `none` - Ignore this table\n\n\u003e All table which not list in track.yml will be `none`.\n\n### Sync Track Tables\n\nIf you installed a new component, there may be multiple tables added to ypur database, you can run:\n\n``` bash \nphp bin/windwalker sql table sync\n```\n\nTo auto add all non-tracked table to `track.yml`\n\n### Status\n\nThis command help you check table track information.\n\n``` bash\nphp bin/windwalker sql status\n```\n\n![p-2016-04-05-006](https://cloud.githubusercontent.com/assets/1639206/14274758/d143e078-fb45-11e5-9e53-c5967f94a5a9.jpg)\n\n### Profiles\n\nYou can change profile by use\n\n``` bash\n# List profile\nphp bin/windwalker sql profile\n\n# Create \u0026 checkout profile\nphp bin/windwalker sql profile create test\nphp bin/windwalker sql profile checkout test\n```\n\nNow you can export schema to other profile, this is very similar to git branches.\n\n### Quick import \u0026 export to profile\n\nYou don't need to always checkout profiles, add profiles as arguments in commands.\n\n``` bash\n# Single profile\nphp bin/windwalker sql export test\n\n# Multiple profiles\nphp bin/windwalker sql export default foo bar test\n\n# Ignore checking prompt\nphp bin/windwalker sql export default foo bar test -y\n\n# Export all profiles\nphp bin/windwalker sql export --all -y\n```\n\nThis operations can support `export` / `import` both commands.\n\n### Rename Column\n\nModify `From` property in your schema files.\n\n``` yaml\ncolumns:\n  oldname: { Field: newname, ... , From: [oldname, oldname2] }\n```\n\nAll oldnames in `From` property will convert to `newname`\n\n\u003e Currently Sqlsync are weak on column name change, try avoid to do this operation.\n\n### Export \u0026 Import Hooks\n\nAdd these files to profile folder.\n\n``` php\npre-export.php\npost-export.php\npre-import.php\npost-import.php\n```\n\nAnd simply write your script to do something.\n\n``` php\n// resources/sqlsync/default/pre-import.php\n\nif (!JFactory::getConfig()-\u003eget('debug'))\n{\n    throw new \\Exception('STOP importing, please enable debug mode to do any DB operations.');\n}\n\n// Or do some advanced DB actions, for instance, rename column or remove indexes.\nJFactory::getDbo()-\u003esetQuery('ALTER TABLE ...')-\u003eexecute();\n\n```\n\n## Seeder\n\nWindwalker Developement Bundle provides a simple seeder and faker tools to help you generate fake data.\n\nOpen `resources/seeders/DatabaseSeeder.php`, you will see `DatabaseSeeder` default class:\n\nAdd a new seeder class at `resources/seeders/ProductSeeder.php`\n\n``` php\nuse Faker\\Factory;\nuse Windwalker\\Data\\Data;\nuse Windwalker\\DataMapper\\DataMapper;\n\nclass ProductSeeder extends \\DevelopmentBundle\\Seeder\\AbstractSeeder\n{\n\tpublic function doExecute()\n\t{\n\t\t$faker = Factory::create();\n\t\t$mapper = new DataMapper('#__mycomponent_products');\n\t\t$categories = (new DataMapper('#__categories'))-\u003efindColumn('id', ['extension' =\u003e 'com_mycomponent']);\n\t\t$userIds = (new DataMapper('#__users'))-\u003eid;\n\n\t\tforeach (range(1, 200) as $i)\n\t\t{\n\t\t\t$data = new Data;\n\t\t\t\n\t\t\t$user_id = JFactory::getUser()-\u003eid;\n\n\t\t\t$data['catid']        = $faker-\u003erandomElement($categories);\n\t\t\t$data['title']        = $faker-\u003esentence(rand(3, 5));\n\t\t\t$data['alias']        = JFilterOutput::stringURLSafe($data['title']);\n\t\t\t$data['temperature']  = $faker-\u003erandomElement(['normal', 'refrigeration', 'freeze']);\n\t\t\t$data['price']        = rand(5000, 10000)/100;\n\t\t\t$data['location']     = $faker-\u003ecountry;\n\t\t\t$data['description']  = $faker-\u003eparagraph(5);\n\t\t\t$data['image']        = $faker-\u003eimageUrl();\n\t\t\t$data['state']        = $faker-\u003erandomElement([1, 1, 1, 1, 1, 0]);\n\t\t\t$data['created']      = $faker-\u003edateTimeThisMonth-\u003eformat('Y-m-d H:i:s');\n\t\t\t$data['created_by']   = $faker-\u003erandomElement($userIds);\n\t\t\t$data['modified']     = $faker-\u003edateTimeThisMonth-\u003eformat('Y-m-d H:i:s');\n\t\t\t$data['modified_by']  = $faker-\u003erandomElement($userIds);\n\t\t\t$data['params']       = '';\n\n\t\t\t$mapper-\u003ecreateOne($data);\n\n\t\t\t$this-\u003ecommand-\u003eout('.', false);\n\t\t}\n\n\t\t$this-\u003ecommand-\u003eout();\n\t}\n\t\n\tpublic function doClear()\n\t{\n\t\t$this-\u003etruncate('#__mycomponent_products');\n\t}\n}\n```\n\nAnd set this class to `DatabaseSeeder`, you must sort seeders by denpendencies.\n\n``` php\n// ...\n\n\tpublic function doExecute()\n\t{\n\t\t$this-\u003eexecute(new CategorySeeder);\n\n\t\t$this-\u003eexecute(new ProductSeeder);\n\n\t\t$this-\u003eexecute(new OrderSeeder);\n\t}\n\n\tpublic function doClear()\n\t{\n\t\t$this-\u003eclear(new CategorySeeder);\n\n\t\t$this-\u003eclear(new ProductSeeder);\n\n\t\t$this-\u003eclear(new OrderSeeder);\n\t}\n```\n\nNow run seeder by:\n\n``` bash\nphp bin/windwalker seed import\n```\n\nOr clear it\n\n``` bash\nphp bin/windwalker seed export\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindwalker-io%2Frad-development-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindwalker-io%2Frad-development-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindwalker-io%2Frad-development-bundle/lists"}