{"id":22764592,"url":"https://github.com/kuria/composer-pkg-scripts","last_synced_at":"2025-07-08T23:34:46.194Z","repository":{"id":54615783,"uuid":"123633968","full_name":"kuria/composer-pkg-scripts","owner":"kuria","description":"Composer plugin that provides a way for packages to expose scripts to the root project","archived":false,"fork":false,"pushed_at":"2023-04-22T14:38:43.000Z","size":25,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T23:16:17.049Z","etag":null,"topics":["composer","composer-plugin","composer-scripts","php"],"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/kuria.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-02T21:42:38.000Z","updated_at":"2023-09-19T17:45:31.000Z","dependencies_parsed_at":"2022-08-13T21:40:33.247Z","dependency_job_id":null,"html_url":"https://github.com/kuria/composer-pkg-scripts","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuria%2Fcomposer-pkg-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuria%2Fcomposer-pkg-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuria%2Fcomposer-pkg-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuria%2Fcomposer-pkg-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuria","download_url":"https://codeload.github.com/kuria/composer-pkg-scripts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975329,"owners_count":21192210,"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":["composer","composer-plugin","composer-scripts","php"],"created_at":"2024-12-11T12:09:25.541Z","updated_at":"2025-04-14T23:16:32.371Z","avatar_url":"https://github.com/kuria.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Composer package scripts\n########################\n\nComposer plugin that provides a way for packages to expose custom scripts\nto the root project. These scripts work similarly to the root-only\nscripts_ option.\n\n.. image:: https://travis-ci.com/kuria/composer-pkg-scripts.svg?branch=master\n   :target: https://travis-ci.com/kuria/composer-pkg-scripts\n\n.. contents::\n   :depth: 2\n\n\nRequirements\n************\n\n- PHP 7.1+\n- Composer 1.6+\n\n\nTerminology\n***********\n\nroot package\n  the main package (project)\n\nroot script\n  a script defined in the root package's scripts_ option\n\npackage script\n  a script defined in a package's ``extra.package-scripts`` option\n\n\nInstallation\n************\n\nSpecify ``kuria/composer-pkg-scripts`` as a dependency in your ``composer.json``.\n\nThis can be done either in the root package or in one of the required packages\n(perhaps a `metapackage? \u003chttps://getcomposer.org/doc/04-schema.md#type\u003e`_).\nThat depends entirely on your use case.\n\n.. code:: javascript\n\n   {\n       // ...\n       \"require\": {\n           \"kuria/composer-pkg-scripts\": \"^1.0\"\n       }\n   }\n\n\nDefining package scripts\n************************\n\nPackage scripts can be defined in the *composer.json*'s extra_ option.\n\nThe syntax is identical to the root-only scripts_ option.\nSee `Composer docs - defining scripts \u003chttps://getcomposer.org/doc/articles/scripts.md#defining-scripts\u003e`_.\n\n.. code:: javascript\n\n   {\n       \"name\": \"acme/example\",\n       // ...\n       \"extra\": {\n           \"package-scripts\": {\n               \"hello-world\": \"echo Hello world!\",\n               \"php-version\": \"php -v\"\n           }\n       }\n   }\n\nThe final script names are automatically prefixed by the package name.\n\nThe example above will define the following scripts:\n\n- ``acme:example:hello-world``\n- ``acme:example:php-version``\n\nTo define shorter aliases, see `Specifying aliases and help`_.\n\n.. NOTE::\n\n   Package scripts will **not** override root scripts_ with the same name.\n\n.. NOTE::\n\n   Package scripts defined in the root package will not be loaded.\n   Use scripts_ instead.\n\n\nReferencing other scripts\n=========================\n\nIn addition to the root scripts_, package scripts may reference other package\nscripts defined in the same file.\n\nSee `Composer docs - referencing scripts \u003chttps://getcomposer.org/doc/articles/scripts.md#referencing-scripts\u003e`_.\n\n.. code:: javascript\n\n   {\n       \"name\": \"acme/example\",\n       // ...\n       \"extra\": {\n           \"package-scripts\": {\n               \"all\": [\"@first\", \"@second\", \"@third\"],\n               \"first\": \"echo first\",\n               \"second\": \"echo second\",\n               \"third\": \"echo third\"\n           }\n       }\n   }\n\nPackage scripts of other packages may be referenced using their full name\nor alias (if it exists). Using the full name should be preferred.\n\n.. code:: javascript\n\n   {\n       \"name\": \"acme/example\",\n       // ...\n       \"extra\": {\n           \"package-scripts\": {\n               \"another-foo\": \"@acme:another:foo\"\n           }\n       }\n   }\n\n\nSpecifying aliases and help\n===========================\n\nPackage script aliases and help can be defined in the *composer.json*'s extra_\noption.\n\n.. code:: javascript\n\n   {\n       \"name\": \"acme/example\",\n       // ...\n       \"extra\": {\n           \"package-scripts\": {\n               \"hello-world\": \"echo Hello world!\",\n               \"php-version\": \"php -v\"\n           },\n           \"package-scripts-meta\": {\n               \"hello-world\": {\"aliases\": \"hello\", \"help\": \"An example command\"},\n               \"php-version\": {\"aliases\": [\"phpv\", \"pv\"], \"help\": \"Show PHP version\"}\n           }\n       }\n   }\n\nUnlike script names, aliases are not automatically prefixed by the package name.\n\nThe example above will define the following scripts:\n\n- ``acme:example:hello-world``\n- ``acme:example:php-version``\n- ``hello``\n- ``phpv``\n- ``pv``\n\n.. NOTE::\n\n   Package script aliases will **not** override root scripts_ or other aliases\n   with the same name.\n\n\nSpecifying aliases in the root package\n--------------------------------------\n\nIf a package doesn't provide suitable aliases, the root package may define them\nin its scripts_ option.\n\n.. code:: javascript\n\n   {\n       \"name\": \"acme/project\",\n       // ...\n       \"scripts\": {\n           \"acme-hello\": \"@acme:example:hello-world\"\n       }\n   }\n\n\nUsing variables\n===============\n\nUnlike root scripts_, package scripts may use variable placeholders.\n\nThe syntax of the placeholder is:\n\n::\n\n  {$variable-name}\n\n- variable name can consist of any characters other than \"}\"\n- nonexistent variables resolve to an empty string\n- the final value is escaped by ``escapeshellarg()``\n- array variables will be imploded and separated by spaces, with each\n  value escaped by ``escapeshellarg()``\n\n\nComposer configuration\n----------------------\n\nAll Composer configuration directives are available through variables.\n\nSee `Composer docs - config \u003chttps://getcomposer.org/doc/06-config.md\u003e`_.\n\n.. code:: javascript\n\n   {\n       \"name\": \"acme/example\",\n       // ...\n       \"extra\": {\n           \"package-scripts\": {\n               \"list-vendors\": \"ls {$vendor-dir}\"\n           }\n       }\n   }\n\n\nPackage variables\n-----------------\n\nPackages may define their own variables in the *composer.json*'s extra_ option.\n\n\n.. code:: javascript\n\n   {\n       \"name\": \"acme/example\",\n       // ...\n       \"extra\": {\n           \"package-scripts\": {\n               \"hello\": \"echo {$name}\"\n           },\n           \"package-scripts-vars\": {\n               \"name\": \"Bob\"\n           }\n       }\n   }\n\nThese defaults may then be overriden in the root package, if needed:\n\n.. code:: javascript\n\n   {\n       \"name\": \"acme/project\",\n       // ...\n       \"extra\": {\n           \"package-scripts-vars\": {\n               \"acme/example\": {\n                   \"name\": \"John\"\n               }\n           }\n       }\n   }\n\n\nReferencing other variables\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nPackage variables may reference `composer configuration directives \u003chttps://getcomposer.org/doc/06-config.md\u003e`_\nor other package variables belonging to the same package.\n\n.. code:: javascript\n\n   {\n       \"name\": \"acme/example\",\n       // ...\n       \"extra\": {\n           \"package-scripts\": {\n               \"hello\": \"echo Hello {$names}\",\n               \"show-paths\": \"echo {$paths}\"\n           },\n           \"package-scripts-vars\": {\n               \"names\": [\"Bob\", \"{$other-names}\"],\n               \"other-names\": [\"John\", \"Nick\"],\n               \"paths\": [\"{$vendor-dir}\", \"{$bin-dir}\"]\n           }\n       }\n   }\n\n.. code:: bash\n\n   composer acme:example:hello\n\n::\n\n  \u003e echo Hello \"Bob\" \"John\" \"Nick\"\n  Hello Bob John Nick\n\n\n.. code:: bash\n\n  composer acme:example:show-paths\n\n::\n\n  \u003e echo \"/project/vendor\" \"/project/vendor/bin\"\n  /project/vendor /project/vendor/bin\n\n\n.. NOTE::\n\n   Array variables must be referenced directly, e.g. ``\"{$array-var}\"``,\n   not embedded in the middle of a string.\n\n   Nested array variable references are flattened into a simple list, as seen\n   in the examples above.\n\n\nRunning package scripts\n***********************\n\nPackage scripts can be invoked the same way root scripts_ can:\n\n1. ``composer run-script acme:example:hello-world``\n2. ``composer acme:example:hello-world``\n\nSee `Composer docs - running scripts manually \u003chttps://getcomposer.org/doc/articles/scripts.md#running-scripts-manually\u003e`_.\n\n\nUsing package scripts in events\n*******************************\n\nPackage scripts may be used in event scripts (provided the plugin is loaded\nat that point).\n\n.. code:: javascript\n\n   {\n       \"name\": \"acme/project\",\n       // ...\n       \"scripts\": {\n           \"post-install-cmd\": \"@acme:example:hello-world\"\n       }\n   }\n\n\nListing package scripts\n***********************\n\nThis plugin provides a command called ``package-scripts:list``, which lists both\nactive and inactive package scripts and aliases.\n\n.. code:: bash\n\n    composer package-scripts:list\n\n::\n\n  Available package scripts:\n    acme:example:hello-world (hello)    An example command\n    acme:example:php-version (phpv, pv) Show PHP version\n\nEnabling verbose mode will show additonal information:\n\n.. code:: bash\n\n  composer package-scripts:list -v\n\n::\n\n  Available package scripts:\n    acme:example:hello-world Run the \"hello-world\" script from acme/example\n     - package: acme/example\n     - definition: \"echo Hello world!\"\n     - aliases:\n    acme:example:php-version Run the \"php-version\" script from acme/example\n     - package: acme/example\n     - definition: \"php -v\"\n     - aliases:\n\nYou may use the ``psl`` alias instead of the full command name.\n\n\nDebugging package scripts and variables\n***************************************\n\nThis plugin provides a command called ``package-scripts:dump``, which dumps\ncompiled scripts (including root scripts) or package script variables.\n\n.. code:: bash\n\n  composer package-scripts:dump\n\nSpecifying the ``--vars`` flag will dump compiled package script variables\ninstead:\n\n.. code:: bash\n\n  composer package-scripts:dump --vars\n\nYou may use the ``psd`` alias instead of the full command name.\n\n\n.. _scripts: https://getcomposer.org/doc/04-schema.md#scripts\n.. _extra: https://getcomposer.org/doc/04-schema.md#extra\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuria%2Fcomposer-pkg-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuria%2Fcomposer-pkg-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuria%2Fcomposer-pkg-scripts/lists"}