Skip to content

Commit 5d5ff6d

Browse files
committed
Initial commit
0 parents  commit 5d5ff6d

File tree

5 files changed

+193
-0
lines changed

5 files changed

+193
-0
lines changed

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Uninstall plugin for Craft CMS
2+
3+
Uninstall misbehaving plugins from the command line. Usage: `./craft/app/etc/console/yiic uninstall --plugin=<pluginHandle>`
4+
5+
**Installation**
6+
7+
1. Unzip file and place `uninstall` directory into your `craft/plugins` directory
8+
2. -OR- do a `git clone https://github.com/khalwat/uninstall.git` directly into your `craft/plugins` folder. You can then update it with `git pull`
9+
3. Install plugin in the Craft Control Panel under Settings > Plugins
10+
11+
##What's it for?
12+
13+
Occasionally, plugins can malfunction to the point where you can't even access the Admin CP to uninstall them. Yes, you can just delete the plugin, but that doesn't allow the plugin to clean up after itself, remove any tables it created, etc.
14+
15+
A fairly typical scenario (at least for me) is that you're developing a Craft plugin, and you make a mistake. Craft is spewing errors, your dog looks at you condescendingly, the place is on fire, and you're looking for an exit.
16+
17+
You'd normally have to either delete the plugin, or go into mysql to do a `mysql> delete from craft_plugins where id = 47;` and then delete the malformed tables your plugin created with `mysql> drop table craft_seomatic_meta;` or what have you. It gets old fast, and no one wants to get old fast.
18+
19+
The Uninstall plugin lets you trigger the normal Craft uninstall process for a plugin from the command line, so Craft and your plugin can clean up after themselves properly.
20+
21+
It'll work even when the Admin CP isn't working, in most cases.
22+
23+
##Using Uninstall
24+
25+
Using Uninstall is pretty easy; just `ssh` into the server your Craft install is running on, `cd` to the Craft project directory and do:
26+
27+
./craft/app/etc/console/yiic uninstall --plugin=<pluginHandle>
28+
29+
Note that the `<pluginHandle>` is case sensitive, and is simply [your plugin’s handle](https://craftcms.com/docs/plugins/setting-things-up#your-primary-plugin-class). This is not the same as the human-readable name of the plugin. Here's an example of Uninstall in operation:
30+
31+
vagrant@homestead:~/sites/nystudio107$ ./craft/app/etc/console/yiic uninstall --plugin=Seomatic
32+
Seomatic uninstalled. Have a nice day.
33+
34+
This just runs `craft()->plugins->uninstallPlugin();` to give Craft and your plugin a chance to clean up and uninstall properly.
35+
36+
##Multi-environment configs
37+
38+
If you're using Craft on a [multi-environment config](https://craftcms.com/docs/multi-environment-configs) (which presumably you are if you're doing development), keep in mind that the `$_SERVER['SERVER_NAME']` may not match any of your criteria in `craft/config/db.php` when it runs from the command line with `yiic`.
39+
40+
This will cause `yiic` to spew errors when you try to use it. To alleviate this, just assign some sane defaults to your `'*'` settings in `craft/config/db.php`, such as this:
41+
42+
'*' => array(
43+
// The prefix to use when naming tables. This can be no more than 5 characters.
44+
'tablePrefix' => 'craft',
45+
46+
// The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
47+
'server' => 'localhost',
48+
49+
// The database username to connect with.
50+
'user' => 'homestead',
51+
52+
// The database password to connect with.
53+
'password' => 'secret',
54+
55+
// The name of the database to select.
56+
'database' => 'nystudio',
57+
),
58+
59+
60+
## Changelog
61+
62+
### 1.0.0 -- 2015.12.08
63+
64+
* Initial release

UninstallPlugin.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
namespace Craft;
3+
4+
class UninstallPlugin extends BasePlugin
5+
{
6+
function getName()
7+
{
8+
return Craft::t('Uninstall Plugin');
9+
}
10+
11+
public function getDescription()
12+
{
13+
return 'Uninstall misbehaving plugins from the command line. Usage: ./craft/app/etc/console/yiic uninstall --plugin=<pluginHandle>';
14+
}
15+
16+
public function getDocumentationUrl()
17+
{
18+
return 'https://github.com/khalwat/uninstall/blob/master/README.md';
19+
}
20+
21+
public function getReleaseFeedUrl()
22+
{
23+
return 'https://github.com/khalwat/uninstall/blob/master/releases.json';
24+
}
25+
26+
public function getVersion()
27+
{
28+
return '1.0.0';
29+
}
30+
31+
public function getSchemaVersion()
32+
{
33+
return '1.0.0';
34+
}
35+
36+
function getDeveloper()
37+
{
38+
return 'nystudio107';
39+
}
40+
41+
function getDeveloperUrl()
42+
{
43+
return 'http://nystudio107';
44+
}
45+
46+
public function hasCpSection()
47+
{
48+
return false;
49+
}
50+
} /* -- UninstallPlugin */
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
namespace Craft;
3+
4+
class UninstallCommand extends BaseCommand
5+
{
6+
7+
public function actionIndex($plugin="")
8+
{
9+
if ($plugin)
10+
{
11+
echo craft()->plugins->uninstallPlugin($plugin);
12+
echo $plugin . " uninstalled. Have a nice day.\n";
13+
}
14+
else
15+
echo "No plugin handle given. Usage: ./craft/app/etc/console/yiic uninstall --plugin=<pluginHandle>\n";
16+
} /* -- actionIndex */
17+
} /* -- class PluginCommand */
18+
?>

releases.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"version": "1.0.0",
4+
"downloadUrl": "https://github.com/khalwat/uninstall/archive/master.zip",
5+
"date": "2015-12-08T11:00:00-05:00",
6+
"notes": [
7+
"[Added] Initial release"
8+
]
9+
}
10+
]

resources/icon.svg

Lines changed: 51 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)