{"id":20173210,"url":"https://github.com/codingexplained/composer-tools","last_synced_at":"2025-03-03T04:41:46.646Z","repository":{"id":111776091,"uuid":"170665689","full_name":"codingexplained/composer-tools","owner":"codingexplained","description":null,"archived":false,"fork":false,"pushed_at":"2019-02-14T16:20:55.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T15:53:02.556Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/codingexplained.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-14T09:38:23.000Z","updated_at":"2019-02-14T16:20:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"fabd9de1-d82e-41eb-bb7f-5c13d3ec1603","html_url":"https://github.com/codingexplained/composer-tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingexplained%2Fcomposer-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingexplained%2Fcomposer-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingexplained%2Fcomposer-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingexplained%2Fcomposer-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codingexplained","download_url":"https://codeload.github.com/codingexplained/composer-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241610975,"owners_count":19990505,"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-14T01:34:12.480Z","updated_at":"2025-03-03T04:41:46.626Z","avatar_url":"https://github.com/codingexplained.png","language":"Python","readme":"# Composer Tools\n\n## Introduction\n\nThis tool is a convenient helper that lets you easily switch from a repository \nversion of a Composer package (VCS repository or Packagist) to a local version \non your local file system (and back). It works by replacing the directory that \nComposer adds with a symbolic link. Why? [Read this blog post.](#) Isn't it a \nhack? Sure it is, but it works and there seems to be no convenient way of doing \nthis right now (AFAIK). This tool doesn't do any magic; it just automates a \nseries of simple commands for you.\n\n#### Requirements\n\nRequires Python 3.7. Currently untested on Windows. If you test it, please let me \nknow how it goes.\n\n#### Warning!\n\nThis is just a quick tool that I hacked together, so use at your own risk! \nIf you want to check how it works under the hood, then I encourage you to \ntake a moment to read through the source code.\n\n## Installation\n\n### Mac/Linux\n\n1. Clone the repository.\n\n```\ngit checkout https://github.com/codingexplained/composer-tools.git\n```\n\n2. Copy `composer-tools.py` into place (and rename it).\n\n```\ncp composer-tools.py /usr/local/bin/composer-tools\n```\n\n3. Give the file executable permission.\n\n```\nchmod +x /usr/local/bin/composer-tools\n```\n\n### Windows\n\nN/A\n\n## Setup\n\nWithin your project's root directory, create a file named `composer.dev.json`, \nwhere you need to configure where packages should be symlinked to locally.\n\n```\n{\n  \"packages\": {\n    \"example/package\": \"/path/to/example/package\"\n  }\n}\n```\n\nYou can also specify relative paths instead, which are relative to the project root.\n\n```\n{\n  \"packages\": {\n    \"example/package\": \"../../example/package\"\n  }\n}\n```\n\nApart from often looking cleaner, relative paths have an added advantage when using \nDocker containers, for instance; if you have mounted your source code with a volume \nand used absolute paths, the symlink is going to be invalid within your container, \nbecause the absolute path on the host OS most likely doesn't exist within the \ncontainer. By using relative paths, all you need to do, is to mount the packages \nrelative to the project root within the container. \n\n## Usage\n\n```\nusage: composer-tools [-h] [--config CONFIG]\n                      [--packages PACKAGES [PACKAGES ...]]\n                      [--composer-install-options COMPOSER_INSTALL_OPTIONS [COMPOSER_INSTALL_OPTIONS ...]]\n                      [--force-absolute]\n                      {ln,reset}\n\nSwitch between local and repository Composer package versions.\n\npositional arguments:\n  {ln,reset}            The action to perform\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --config CONFIG       Specify the path to the configuration file instead of\n                        using the default location\n  --packages PACKAGES [PACKAGES ...]\n                        Specify packages for which the action should be\n                        performed. Currently only supported for the \"ln\"\n                        action\n  --composer-install-options COMPOSER_INSTALL_OPTIONS [COMPOSER_INSTALL_OPTIONS ...]\n                        Specify options passed to \"composer install\"\n  --force-absolute      Force generated paths to be absolute\n```\n\n### Symlinking local package\n\nTo symlink packages to their local versions instead of the repository versions, use the following command:\n\n```\ncomposer-tools ln\n```\n\n### Symlinking specific packages\n\nBy default, all packages defined within the configuration file are symlinked. \nYou may, however, specify one or more packages instead.\n\n```\ncomposer-tools ln --packages vendor/package1 vendor/package2\n```\n\n**NOTE:** This only works with the `ln` command. This is because the `reset` \ncommand runs `composer install`, which reverts all packages to those defined \nwithin the `composer.lock` file. Unfortunately the `install` command does not \naccept specific packages as an argument, and we don't want to run the \n`update` command and disrespect what is written within `composer.lock`.\n\n### Resetting to repository packages\n\nTo reset packages to the version defined within `composer.lock`, run the following command:\n\n```\ncomposer-tools reset\n```\n\nThis removes the symbolic links to the local packages and runs `composer install`. \n\n### Specifying the configuration file path\n\nBy default, the tool looks for a file named `composer.dev.json` in the current \nworking directory (the project root). You can, however, specify the path to the \nconfiguration file instead.\n\n```\ncomposer-tools ln --config /path/to/config.json\n```\n\n### Forcing absolute paths\n\nGiven that you used relative paths within your configuration file, the generated \nsymlinks are also going to use relative paths. If you want to force all paths to \nbe absolute, you can specify the `force-absolute` flag. This will make all paths \nabsolute, even if a configured path is relative.\n\n```\ncomposer-tools ln --force-absolute\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingexplained%2Fcomposer-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodingexplained%2Fcomposer-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingexplained%2Fcomposer-tools/lists"}