Dependency Inception: Composer Running NPM and Bower
What a pretty little world we have created for ourselves. Dependency Injection and Package Management are the basis for development in the modern era – I am feeling poetic today. What happens if we can have one package management solution, running another package management solution, running a third package management solution.
I needed a way to configure some Bower packages into my Symfony project, and I didn’t want to worry about the packages when updating with the Continuous Deployment scenario. We’ll start nice and easy, having jQuery download and install when running
Running commands in Symfony is simple. We need to create a class that will handle the running of the process.
Next we’ll setup the Bower scripts in the base directory of our project.
And the .bowerrrc file to configure our install location. I am using the app/Resources directory.
Then include the call in the
composer.json file, as follows.
I put the script to run early in the process, so the downloaded script would be available when running Assetic. Now when running
composer install or
composer update or ScriptHandler will be called.
Including these files into your Assetic configuration is nice and easy too. Just reference the
%kernel.root_dir% and we’re away.
You remind me of someone… a man I met in a half-remembered dream
Okay. No guarantees here. You choose to do this, you are on your own. I am not even sure having Composer handle Bower is a great idea – I would think that having the deployment process call each package manager a better idea. But this is not a post about good ideas.
package.json file. This one is similar to the Angular Tutorial.
And include the Angular dependencies into the Assetic code:
Now you have Composer, installing NPM packages, which is calling the Bower install. I don’t know if it is a good idea, but it works okay.
Update the .gitignore file to ignore Bower and NPM packages.
Sorry, the comment form is closed at this time.