Adding Npm to a PHP Travis Project
Like most PHP developers, I’m polyglot. My PHP project builds with phing, but uses a bunch of npm tools along the way to minify assets and those types of things. When I introduced TravisCI into my project, I was instantly confused by the requirement to specify the technology I was using … all of them, surely?
In need of wisdom and advice, I turned to the best source I know:
How do people use @travisci with multiple languages? Project uses PHP and nodejs tools but I can't seem to configure both. Any links/advice?
— Lorna Mitchell (@lornajane) May 7, 2014
The answer came back from @Ocramius (thankyou!) who linked to a .travis.yml
showing how to use the stock nodejs’ npm to add tools in the before_script
segment, like this:
before_script:
- npm install -g grunt-cli
- npm install
Then I can just include a grunt
call in my script:
section, and all is well. I had a hard time finding this so I thought I’d put it here for next time I need it (and anyone else who might find it handy).