{"id":23611035,"url":"https://github.com/magepsycho/composer-patch-creator","last_synced_at":"2025-11-06T04:30:30.225Z","repository":{"id":269845211,"uuid":"904810452","full_name":"MagePsycho/composer-patch-creator","owner":"MagePsycho","description":"PHP Composer Patch Creator","archived":false,"fork":false,"pushed_at":"2024-12-26T15:30:18.000Z","size":488,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-26T16:18:16.416Z","etag":null,"topics":["bash","laravel","magento","php","shopware","slimphp","symfony","yii"],"latest_commit_sha":null,"homepage":"https://www.magepsycho.com/","language":"Shell","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/MagePsycho.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":"2024-12-17T15:42:01.000Z","updated_at":"2024-12-26T15:31:57.000Z","dependencies_parsed_at":"2024-12-26T16:18:18.119Z","dependency_job_id":"bd702c70-0194-47d4-979b-9e9256c7e81f","html_url":"https://github.com/MagePsycho/composer-patch-creator","commit_stats":null,"previous_names":["magepsycho/composer-patch-creator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagePsycho%2Fcomposer-patch-creator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagePsycho%2Fcomposer-patch-creator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagePsycho%2Fcomposer-patch-creator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagePsycho%2Fcomposer-patch-creator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MagePsycho","download_url":"https://codeload.github.com/MagePsycho/composer-patch-creator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239483350,"owners_count":19646419,"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":["bash","laravel","magento","php","shopware","slimphp","symfony","yii"],"created_at":"2024-12-27T16:12:43.123Z","updated_at":"2025-11-06T04:30:30.183Z","avatar_url":"https://github.com/MagePsycho.png","language":"Shell","readme":"# PHP Composer Patch Creator\n\n## 🛠 Overview\n\nA robust and lightning-fast Bash utility script designed to simplify and accelerate the process of creating and managing vendor package patches for Composer-based PHP projects (such as Magento, Laravel, Symfony, etc.).\n\nThis is likely the quickest and most efficient way to generate Composer-compatible patches for vendor packages, saving developers significant time and effort.\n\n## 🚀 Why Use This Script?\n\n### Traditional Patch Creation Workflow\n```bash\n# Manually stage specific files\ngit add -f ./vendor/{vendor}/{package}/file1.php ./vendor/{vendor}/{package}/file2.php ...\n\n# Perform required changes on files\n# ... (manual editing)\n\n# Create patch manually\ngit diff ./vendor/{vendor}/{package}/file1.php ./vendor/{vendor}/{package}/file2.php ... \u003e patches/{patch-name}.patch\n\n# Cleanup steps\ngit restore ./vendor/{vendor}/{package}/file1.php ./vendor/{vendor}/{package}/file2.php ...\ngit reset HEAD ./vendor/{vendor}/{package}/file1.php ./vendor/{vendor}/{package}/file2.php ...\n\n# OR If you are using diff command\n# cp ./vendor/{vendor}/{package}/file.php ./vendor/{vendor}/{package}/file.php.old\n# {perform required changes on file.php}\n# diff -u ./vendor/{vendor}/{package}/file.php.old ./vendor/{vendor}/{package}/file.php \u003e patches/{patch-name}.patch\n# rm ./vendor/{vendor}/{package}/file.php\n# mv ./vendor/{vendor}/{package}/file.php.old ./vendor/{vendor}/{package}/file.php\n\n# Manually update composer.json\n\"extra\": {\n    \"patches\": {\n        \"{vendor}/{package}\": {\n            \"{patch-message}\": \"patches/{patch-name}.patch\",\n        },\n    }\n}\n```\n\n### With Composer Patch Creation Utility\n```bash\n# Single command to start patch creation\ncpc {vendor}/{package} -n {patch-name}.patch -m {patch-message}\n\n# Perform required changes in vendor repo files\n# Press 'y' when done\n\n# Automatic patch generation and composer.json update ✨\n```\n\n### 🌟 Key Benefits\n- **Simplified Workflow**: Reduce multiple manual steps to a single command\n- **Automatic File Management**:\n    - Automatically stages files\n    - Generates patch\n    - Restores original files\n    - Cleans up git staging\n- **Composer.json Integration**:\n    - Automatically updates patch configuration\n    - Creates backup before modification\n- **Interactive Process**:\n    - Guides you through patch creation\n    - Provides clear prompts and feedback\n- **Error Handling**:\n    - Checks dependencies\n    - Validates input\n    - Provides detailed error messages\n\n## 📦 Prerequisites\n\n### Required Tools\n- `git`\n- `composer`\n- `jq`\n- Standard Unix tools (`cp`, `mkdir`, `sed`, `date`)\n- Composer Patches Plugin: `cweagans/composer-patches`\n\n### Supported Environments\n- Linux\n- macOS\n\n## 🚀 Installation\n\n1. Clone the script to your project:\n```bash\ncurl -0 https://raw.githubusercontent.com/MagePsycho/composer-patch-creator/main/src/composer-patch-creator.sh -o cpc.sh\nchmod +x cpc.sh\n```\n\nTo make it system-wide command\n```bash\nsudo mv cpc.sh /usr/local/bin/cpc\n```\n\n2. Ensure all dependencies are installed\n\n## 💡 Usage\n\n### Basic Usage\n```bash\n./cpc.sh \u003cvendor/package\u003e\n```\n\n### Advanced Options\n```bash\n# Custom patch name\n./cpc.sh magento/module-url-rewrite -n TICKET-custom-patch.patch\n\n# Patch with description\n./cpc.sh magento/module-url-rewrite -m \"Fixed critical URL rewrite bug\"\n\n# Full example\n./cpc.sh magento/module-url-rewrite -n TICKET-123.patch -m \"Resolved routing issue\"\n```\n\n### Options\n- `-h, --help`: Show help message\n- `-n, --name`: Specify custom patch filename\n- `-m, --message`: Add patch description\n\nOnce the script execution is complete, run the `composer install` command to apply the patches.  \nFor more details, refer to the `Composer Configuration` section.\n\n\u003e [!CAUTION]\n\u003e Only edit the files **after you run the command**.  \n\u003e Changes made prior to running the command won't be detected.\n\n### In Action (Screenshots)\n![Composer Patch Creator - Help](https://github.com/MagePsycho/composer-patch-creator/raw/main/docs/composer-patch-creator-help.png \"Composer Patch Creator - Help\")\n*Fig: help command*\n\n![Composer Patch Creator - Creator](https://github.com/MagePsycho/composer-patch-creator/raw/main/docs/composer-patch-creator-in-action.png \"Composer Patch Creator - Creator\")\n*Fig: patch command in action*\n\n## 🔍 How It Works\n\n1. Checks system dependencies\n2. Validates vendor package existence\n3. Stages vendor package files\n4. Prompts for file modifications\n5. Creates patch file\n6. Updates `composer.json` with patch information\n\n## 📝 Composer Configuration\n\nEnsure your `composer.json` has patch plugin configuration:\n\n```json\n{\n    \"require\": {\n        \"cweagans/composer-patches\": \"^1.7\"\n    },\n    \"extra\": {\n        \"patches\": {}\n    }\n}\n```\n\n## ⚠️ Best Practices\n\n- Always review patches before applying\n- Use descriptive patch names\n- Keep patch files version-controlled\n- Minimize patch scope and complexity\n\n## 🐛 Troubleshooting\n\n- Ensure you're in a git repository\n- Verify all dependencies are installed\n- Check file permissions\n- Confirm `composer.json` is present\n\n## 📄 License\nMIT License\n\n## 👥 Contributing\nContributions welcome! Please open issues or submit pull requests.\n\n## 🙌 Credit\nDeveloped with ❤️ by Raj KB \u003cmagepsycho@gmail.com\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagepsycho%2Fcomposer-patch-creator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagepsycho%2Fcomposer-patch-creator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagepsycho%2Fcomposer-patch-creator/lists"}