{"id":26418296,"url":"https://github.com/ghostwriter/draft","last_synced_at":"2026-04-19T10:33:23.068Z","repository":{"id":37797458,"uuid":"495600644","full_name":"ghostwriter/draft","owner":"ghostwriter","description":"[wip]A code generation tool for Laravel developers.","archived":false,"fork":false,"pushed_at":"2025-03-16T00:22:12.000Z","size":395,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"0.1.x","last_synced_at":"2025-03-16T00:23:44.777Z","etag":null,"topics":["code-generator","ghostwriter","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ghostwriter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["ghostwriter"]}},"created_at":"2022-05-23T23:09:17.000Z","updated_at":"2025-03-16T00:22:15.000Z","dependencies_parsed_at":"2024-05-01T16:37:03.734Z","dependency_job_id":"e67bbd82-edf0-4aa5-845e-e88c23194501","html_url":"https://github.com/ghostwriter/draft","commit_stats":{"total_commits":135,"total_committers":1,"mean_commits":135.0,"dds":0.0,"last_synced_commit":"ecdc9504272949ba047576778a558039acb677c8"},"previous_names":["ghostwriter/laravel-draft","ghostwriter/draft"],"tags_count":0,"template":false,"template_full_name":"ghostwriter/wip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fdraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fdraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fdraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fdraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostwriter","download_url":"https://codeload.github.com/ghostwriter/draft/tar.gz/refs/heads/0.1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244135873,"owners_count":20403798,"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":["code-generator","ghostwriter","laravel","php"],"created_at":"2025-03-18T01:17:33.698Z","updated_at":"2026-04-19T10:33:18.037Z","avatar_url":"https://github.com/ghostwriter.png","language":"PHP","funding_links":["https://github.com/sponsors/ghostwriter"],"categories":[],"sub_categories":[],"readme":"# Draft\n\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/ghostwriter?label=Sponsor+@ghostwriter/draft\u0026logo=GitHub+Sponsors)](https://github.com/sponsors/ghostwriter)\n[![Automation](https://github.com/ghostwriter/draft/actions/workflows/automation.yml/badge.svg)](https://github.com/ghostwriter/draft/actions/workflows/automation.yml)\n[![Supported PHP Version](https://badgen.net/packagist/php/ghostwriter/draft?color=8892bf)](https://www.php.net/supported-versions)\n[![Downloads](https://badgen.net/packagist/dt/ghostwriter/draft?color=blue)](https://packagist.org/packages/ghostwriter/draft)\n\nA code generation tool for Laravel developers.\n\n\u003e **Warning**\n\u003e\n\u003e This project is not finished yet, work in progress.\n\nThis tool will write your draft ideas in to functional laravel code.\n\n- Automatically load existing files and database to generate missing files. (e.g. Missing Tests)\n- Fully written Tests for each file generated\n- Jetstream with Livewire by v1.0\n\n### Automated Features\n- Models\n- Factories\n- Seeders\n- Migrations\n- Routes\n- Unit Tests (90+ code coverage by v1.0)\n- Feature Tests (90+ code coverage by v1.0)\n- Controllers\n  - FormRequest\n  - Middleware\n  - Gates \u0026 Policies\n  - ResourceCollections\n  - Statements\n    - Mails\n    - Notifications\n    - Jobs\n    - Events\n    - RenderView\n\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require ghostwriter/draft --dev\n```\n\n## Usage\n\n### Commands\n\ncreate a draft file.\n\n``` bash\nphp artisan draft:init\n```\n\nbuild the laravel application using the draft.php file\n\n``` bash\nphp artisan draft:build\n```\n\ngenerate missing and or incomplete files along with writing feature/unit tests.\n\n``` bash\nphp artisan draft:generate\n```\n\ntrace an existing application to build a \"draft.php\" file.\n\n``` bash\nphp artisan draft:trace\n```\n\n### Draft file: `draft.php`\n\n```php\n\u003c?php\n\n// Note: Some if not most of the syntax below may change, I'm cleaning it up and building an API.\n\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Ghostwriter\\Draft\\Application\\Definition\\Action\\LivewireActionDefinition;\nuse Ghostwriter\\Draft\\Application\\Definition\\LivewireDefinition;\nuse Ghostwriter\\Draft\\Application\\Definition\\Router\\RouteGroupDefinition;\nuse Ghostwriter\\Draft\\Application\\Definition\\RouterDefinition;\nuse Ghostwriter\\Draft\\Draft;\nuse Ghostwriter\\Draft\\Application\\Definition\\Action\\ControllerActionDefinition;\nuse Ghostwriter\\Draft\\Application\\Definition\\Action\\InertiaActionDefinition;\nuse Ghostwriter\\Draft\\Application\\Definition\\ControllerDefinition;\nuse Ghostwriter\\Draft\\Application\\Definition\\InertiaDefinition;\nuse Ghostwriter\\Draft\\Application\\Definition\\MigrationDefinition;\nuse Ghostwriter\\Draft\\Application\\Definition\\ModelDefinition;\nuse Ghostwriter\\Draft\\Application\\Definition\\Test\\TestCaseDefinition;\nuse Ghostwriter\\Draft\\Application\\Definition\\TestDefinition;\n\n$resourceActions = ['index', 'create', 'edit', 'show', 'store', 'update', 'destroy'];\n\nreturn static function (Draft $draft): void {\n    $draft-\u003emodel('Comment', function (ModelDefinition $definition): void {\n        $modelDefinition-\u003erelationships('author')-\u003ehasOne('User');\n        $modelDefinition-\u003erelationships('post')-\u003ehasOne('Post');\n    });\n    $draft-\u003emodel('Post', function (ModelDefinition $definition): void {\n        $modelDefinition-\u003erelationships('author')-\u003ehasOne('User');\n        $modelDefinition-\u003erelationships('comments')-\u003ehasMany('Comment');\n        $modelDefinition-\u003erelationships('tags')-\u003ebelongsToMany('Tag');\n//       $definition-\u003ecasts();\n//       $definition-\u003econtroller();\n//       $definition-\u003efillable();\n//       $definition-\u003ehidden();\n//       $definition-\u003emigration();\n//       $definition-\u003ename();\n//       $definition-\u003erelationships();\n//       $definition-\u003eresourceController();\n//       $definition-\u003etable();\n//       $definition-\u003etest();\n\n    });\n    $draft-\u003emigration('Post', function (MigrationDefinition $migrationDefinition): void {\n        $migrationDefinition-\u003eid();\n        $migrationDefinition-\u003eforeignId('user_id');\n        $migrationDefinition-\u003estring('title', 150);\n        $migrationDefinition-\u003etext('content');\n        $migrationDefinition-\u003etimestamp('published_at')-\u003enullable();\n        $migrationDefinition-\u003etimestamps();\n        $migrationDefinition-\u003esoftDeletes();\n    });\n    $draft-\u003emigration('Comment', function (MigrationDefinition $migrationDefinition): void {\n        $migrationDefinition-\u003eid();\n        $migrationDefinition-\u003eforeignId('post_id');\n        $migrationDefinition-\u003eforeignId('user_id');\n        $migrationDefinition-\u003etext('content');\n        $migrationDefinition-\u003etimestamp('published_at')-\u003enullable();\n        $migrationDefinition-\u003etimestamps();\n        $migrationDefinition-\u003esoftDeletes();\n    });\n    $draft-\u003econtroller('PostController', function (ControllerDefinition $controllerDefinition): void {\n        $controllerDefinition-\u003eresource('posts');\n\n        $controllerDefinition-\u003eaction('posts.hide', function (ControllerActionDefinition $controllerActionDefinition): void {\n            $controllerActionDefinition-\u003eformRequest('HidePostRequest', [\n                'reason' =\u003e 'required',\n            ]);\n\n            $controllerActionDefinition-\u003evalidate([\n                'reason' =\u003e 'required',\n            ]);\n\n            $controllerActionDefinition-\u003esave('post');\n            $controllerActionDefinition-\u003esend('PostHiddenNotification', 'post.author', ['post']);\n            $controllerActionDefinition-\u003edispatch('HidePost', ['post']);\n            $controllerActionDefinition-\u003efire('HidePost', ['post']);\n            $controllerActionDefinition-\u003eflash('success', 'post.title was successfully hidden.');\n            $controllerActionDefinition-\u003erender('posts.show', ['post']);\n        });\n    });\n\n    $draft-\u003erouter( function (RouterDefinition $routerDefinition): void {\n        $routerDefinition-\u003eview('/', 'welcome');\n\n        $routerDefinition-\u003egroup(function (RouteGroupDefinition $routeGroupDefinition) {\n            $middleware = ['web', 'auth'];\n            \n            $name = 'Comment';\n            $singular = Str::singular(Str::snake($name)); // comment\n            $plural = Str::plural($singular); // comments\n            $model = Str::studly($singular); // Comment\n            \n            $routeGroupDefinition-\u003emiddleware($middleware)\n                                 -\u003eprefix($plural)\n                                 -\u003ename($plural . '.');\n            \n            $namespace = '\\\\App\\\\Livewire\\\\' . $model .'\\\\';\n            \n            $create = $namespace . 'Create' . $model;\n            $delete = $namespace . 'Delete' . $model;\n            $edit = $namespace . 'Edit' . $model;\n            $index = $namespace . 'Index' . $model;\n            $show = $namespace . 'Show' . $model;\n            $store = $namespace . 'Store' . $model;\n            $update = $namespace . 'Update' . $model;\n            \n            $routeGroupDefinition-\u003edelete('/{'.$singular.'}', $delete)-\u003ename('destroy');\n            $routeGroupDefinition-\u003eget('/', $index)-\u003ename('index');\n            $routeGroupDefinition-\u003eget('/create', $create)-\u003ename('create');\n            $routeGroupDefinition-\u003eget('/{'.$singular.'}', $show)-\u003ename('show');\n            $routeGroupDefinition-\u003eget('/{'.$singular.'}/edit', $edit)-\u003ename('edit');\n            $routeGroupDefinition-\u003epatch('/{'.$singular.'}', $update)-\u003ename('update');\n            $routeGroupDefinition-\u003epost('/', $store)-\u003ename('store');\n            $routeGroupDefinition-\u003eput('/{'.$singular.'}', $update)-\u003ename('update');\n        });\n        \n        $routerDefinition-\u003eget('contact', 'ContactController')-\u003ename('contact');\n\n        $routerDefinition-\u003ename('posts.hide');\n        $routerDefinition-\u003eresource('posts');\n\n    });\n\n    $draft-\u003etest('Post', function (TestDefinition $testDefinition): void {\n        $testDefinition-\u003etest(\n            'user can see all of their own posts',\n            function (TestCaseDefinition $testCaseDefinition): void {\n                // $testCaseDefinition-\u003ename();\n            });\n    });\n    \n    $draft-\u003elivewire('auth.login', function (LivewireDefinition $livewireDefinition) :void {\n        $livewireDefinition-\u003emount('user');\n        $livewireDefinition-\u003eaction('login', function (LivewireActionDefinition $livewireActionDefinition));\n    });\n\n    $draft-\u003einertia('auth.logout', function (InertiaDefinition $inertiaDefinition) :void {\n        $inertiaDefinition-\u003eaction('logout', function (InertiaActionDefinition $inertiaActionDefinition) : void {\n\n        });\n    });\n};\n```\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG.md](./CHANGELOG.md) for more information what has changed recently.\n\n## Security\n\nIf you discover any security related issues, please email `nathanael.esayeas@protonmail.com` instead of using the issue tracker.\n\n## Support\n\n[[`Become a GitHub Sponsor`](https://github.com/sponsors/ghostwriter)]\n\n## Credits\n\n- [Nathanael Esayeas](https://github.com/ghostwriter)\n- [All Contributors](https://github.com/ghostwriter/draft/contributors)\n\n## License\n\nThe BSD-3-Clause. Please see [License File](./LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Fdraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostwriter%2Fdraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Fdraft/lists"}