A blog probably of interest only to nerds by John Morton.

20Jul2018

Remov­ing Craft CMS plu­g­ins that you can’t uninstall

I was recent­ly updat­ing my site and decid­ed to use Michael Rog’s Word­smith plu­g­in for some text manip­u­la­tion. His Word­smith plu­g­in includ­ed some fea­tures that I liked that my own cus­tom plu­g­in, a sim­ple port of Hack­saw, didn’t include. I had cre­at­ed this plu­g­in when Craft 3 was ear­ly in devel­op­ment, a time when there were many few­er plu­g­ins avail­able and no plu­g­in store at all. 

Installing plu­g­ins through Craft 3’s Plu­g­in Store makes things very easy. Unin­stalling plu­g­ins is also very easy. As you can see by the screen­shot above, the Pic Puller plu­g­in has a con­ve­nient unin­stall option in the con­trol panel. 

But, my cus­tom hack­saw” plug-in does not have an unin­stall option. At first glance I won­dered how to get rid of this cus­tom plu­g­in. It occurred to me I would unin­stall it the same way I had installed this cus­tom plug-in. Com­pos­er.

A quick refresher

I’ve got this cus­tom plu­g­in built on my local machine. It lives in a direc­to­ry called local-plugins/hacksaw in the base direc­to­ry for my site, right next to the config, src, and web directories.

In my site’s composer.json file, I have told com­pos­er to look in this direc­to­ry when installing plu­g­ins via the com­mand line. In my case, my composer.json con­tains this:

"repositories": [
        {
            "type": "path",
            "url": "local-plugins/hacksaw/"
        }
    ]

That allowed me to install my local plu­g­in, which is iden­ti­fied in its own composer.json file by the name of jmx2hacksaw/​hacksaw”, by using this command:

composer require jmx2hacksaw/hacksaw

Unin­stalling

Now that I don’t need this local plu­g­in any­more, get­ting rid of it is basi­cal­ly undo­ing my require command:

composer remove jmx2hacksaw/hacksaw

The local plu­g­in is now removed.