Package Development: Remove published views when package is removed
Really stuck on this problem.
Basically I have built a Laravel Package that has some views that can be published. Now, what I want is that when a user installs the package and publishes its assets and then when the user uninstalls the package either by running composer remove package or removing the entry from the package.json file and running composer update, it should remove the published views as well.
I think that I can make some changes in the package composer.json file but its not working. I think composer scripts are the solution but right now can't implement them.
You can use the post-package-uninstall event from composer to perform some calls in your package. You can find that in the documentation of composer here: https://getcomposer.org/doc/articles/scripts.md
Basically you will end up with something like this
@BOBBYBOUWMANN - I am using windows. So, when I would remove the package in windows it does not work. Will it work on Linux only. Also, I am going to add this to the package composer.json and every user who installs my package will have the functionality?
As long as it's the composer.json of your package it should work for everyone.
Like I mentioned, the script might not work for everyone depending on the system. So instead I can recommend you to use the class base approach and write your logic in there to remove files!