Composer won't execute post require hooks when installing from packagist.org

593 views
Skip to first unread message

Python Coder

unread,
Nov 25, 2015, 10:27:45 AM11/25/15
to composer-dev
Hey everyone

I am trying to execute a php script when a composer module is installed when issuing a command such as composer require vendor/package-name.

The composer json of the package looks like this:

{ "name": "vendor/package-name", "description": "some description", "type": "library", "license": "MIT", "authors": [{ "name": "author", "email": "ma...@packagist.org", "homepage": "http://example.com" }], "minimum-stability": "stable", "require": { "php": ">=5.3.0" }, "autoload": { "psr-4": {"PmbaTestPackage\\": "src/"} }, "scripts": { "pre-install-cmd": [ "php src/notify.php" ], "post-update-cmd": [ "php src/notify.php" ] }, "version": "1.0.1" }

And I want to execute the script at php/notify.php when the module is required. I looked at the hooks described here: https://getcomposer.org/doc/articles/scripts.md

But it doesn't work, no hooks are executed? What is the reason?

Hari K T

unread,
Nov 25, 2015, 11:30:31 AM11/25/15
to compos...@googlegroups.com
It should work like a charm.

Try this example. composer.json

{
    "scripts": {
        "post-update-cmd": "touch hello.txt"
    }
}

composer require aura/auth

If you look at your directory you will see a hello.txt .

I feel there is some issue on the notify script or execution of script.

Thank you

Hari K T

You can ring me : +91 9388 75 8821

Skype  : kthari85
Twitter : harikt

--
--
You received this message because you are subscribed to the "composer-dev" group.
To post to this group, send email to compos...@googlegroups.com
To unsubscribe from this group, send email to
composer-dev...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/composer-dev?hl=en

---
You received this message because you are subscribed to the Google Groups "composer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to composer-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christophe COEVOET

unread,
Nov 25, 2015, 11:42:18 AM11/25/15
to compos...@googlegroups.com
Only hooks of the root package are executed, as explained in the composer documentation
-- 
Christophe | Stof
Reply all
Reply to author
Forward
0 new messages