{"id":36385292,"url":"https://github.com/absszero/phead","last_synced_at":"2026-01-11T15:01:33.366Z","repository":{"id":215541245,"uuid":"727126014","full_name":"absszero/phead","owner":"absszero","description":"A PHP code generator to generate code via your LAYOUT file.","archived":false,"fork":false,"pushed_at":"2025-08-13T01:24:06.000Z","size":61,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-09T13:53:56.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/absszero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-12-04T08:35:26.000Z","updated_at":"2025-08-13T01:24:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"941a544a-ae64-4217-9b95-8de629382a4b","html_url":"https://github.com/absszero/phead","commit_stats":null,"previous_names":["absszero/phead"],"tags_count":3,"template":false,"template_full_name":"rogervila/composer-package-template","purl":"pkg:github/absszero/phead","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/absszero%2Fphead","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/absszero%2Fphead/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/absszero%2Fphead/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/absszero%2Fphead/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/absszero","download_url":"https://codeload.github.com/absszero/phead/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/absszero%2Fphead/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28309518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-11T15:00:47.990Z","updated_at":"2026-01-11T15:01:33.349Z","avatar_url":"https://github.com/absszero.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phead\n\nA PHP code generator to generate code via your LAYOUT file.\n\n[![Build Status](https://github.com/absszero/phead/workflows/build/badge.svg)](https://github.com/absszero/phead/actions)\n\n\n## Installation\n\n1. Install the package:\n    ```shell\n    composer global require absszero/phead\n    ```\n\n2. Set up Composer bin path:\n\n    ### Linux / macOS\n\n    ```bash shell\n    # Bash shell\n    echo 'export PATH=\"$PATH:~/.composer/vendor/bin\"' \u003e\u003e ~/.bashrc\n    source ~/.bashrc\n\n    # Z shell\n    echo 'export PATH=\"$PATH:~/.composer/vendor/bin\"' \u003e\u003e ~/.zshrc\n    source ~/.zshrc\n\n    # Fish shell\n    fish_add_path ~/.composer/vendor/bin\n    ```\n\n    ### Windows\n     1. Right click on Start up -\u003e System -\u003e Advance system settings -\u003e Environment variables -\u003e System variables[below box] -\u003e Select Path and click Edit.\n     2. Click New and add this value `%USERPROFILE%\\AppData\\Roaming\\Composer\\vendor\\bin`.\n\n\n## Usage\n\n### From Sample\n\n\n```shell\n# Get a sample layout file.\n$ phead --sample my-layout.yaml\n\nmy-layout.yaml is generated.\n\n# Generate code via your layout file.\n$ phead my-layout.yaml\n\nGenerating files...\nHello/MyController.php\nHello/MyModel.php\n```\n\n### Dry run\n\n```shell\n$ phead my-layout.yaml --dry\n\nGenerating files... (dry run)\nHello/MyController.php (skip)\nHello/MyModel.php (skip)\n```\n\n### Overwrite files\n\nExisting files will not be regenerated, you can overwrite with `--force`.\n\n\n```shell\n$ phead my-layout.yaml --force\n\nGenerating files... (force)\nHello/MyController.php (overwrite)\nHello/MyModel.php (overwrite)\n```\n\n### Only those files\n\nOnly those file keys will be generated.\n\n```shell\n$ phead my-layout.yaml --only=model1,model2\n\nGenerating files...\nHello/MyModel1.php\nHello/MyModel2.php\n```\n\n## Layout\n\nLayout file has two main parts:\n\n- `$globals`: The global variables.\n- `$files`: The files for auto generation.\n\n```yaml\n$globals:\n  dir: Hello\n  # Define a variable via environment variable\n  user: '{{ $env.USER }}'\n\n$files:\n  # The file key\n  model:\n\n    # The file variables.\n    # 'namespace', 'class' variables will be auto generated via 'to' path\n    vars:\n      foo: bar\n      # Overwrite default namespace\n      namespace: App\\Hello\n\n    # 'from', 'to' are required\n    # 'from' can also be a stub file path,\n    # EX. from: /my/stub/file.stub\n    from: |\n      \u003c?php\n\n      namespace {{ namespace }};\n\n      class {{ class }}\n      {\n          public $foo = '{{ foo }}';\n      }\n    to: \"{{ $globals.dir }}/MyModel.php\"\n  controller:\n    from: |\n      \u003c?php\n\n      namespace {{ namespace }};\n\n      class {{ class }}\n      {\n          public index()\n          {\n            // {{ $files.model }} will be replaced with \\App\\Hello\\MyModel\n            $model = new {{ $files.model }};\n          }\n      }\n    to: \"{{ $globals.dir }}/MyController.php\"\n    # Append new methods to the class file\n    methods:\n      - |\n        public function get()\n        {\n            return 'something';\n        }\n\n  test:\n   # Skip the file\n   skip: true\n   from: |\n      \u003c?php\n\n      namespace {{ namespace }};\n\n      class {{ class }}\n      {\n          public testSomething()\n          {\n          }\n      }\n   to: \"{{ $globals.dir }}/MyTest.php\"\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabsszero%2Fphead","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabsszero%2Fphead","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabsszero%2Fphead/lists"}