Create Custom Side Menus
Frodo's Ghost | Dependency Inception: Composer Running NPM and Bower
post-template-default,single,single-post,postid-50637,single-format-standard,eltd-core-1.0.1,ajax_fade,page_not_loaded,,borderland - frodosghost-child-ver-1.0.0,borderland-ver-1.2, vertical_menu_with_scroll,smooth_scroll,side_menu_slide_with_content,width_470,paspartu_enabled,paspartu_on_bottom_fixed,wpb-js-composer js-comp-ver-4.4.4,vc_responsive
Packagamen Management Inception

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.

Dependency Inception

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 composer update.

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.

Add NPM package.json file. This one is similar to the Angular Tutorial.

Update the composer.json file

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.

No Comments

Sorry, the comment form is closed at this time.