Skip to content

Commit 5b5e1ef

Browse files
update
1 parent 7b80b6a commit 5b5e1ef

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

composer.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tamedevelopers/database",
3-
"type": "library",
3+
"type": "composer-plugin",
44
"description": "Lightweight PHP ORM Database Model.",
55
"keywords": ["php orm database", "orm database", "php database", "php orm github"],
66
"homepage": "https://github.com/tamedevelopers/database",
@@ -18,15 +18,8 @@
1818
"require": {
1919
"php": ">=8.0",
2020
"tamedevelopers/support": "^5.0",
21-
"symfony/console": "^6.0"
22-
},
23-
"scripts": {
24-
"post-install-cmd": [
25-
"Tamedevelopers\\Database\\Installer::postInstall"
26-
],
27-
"post-update-cmd": [
28-
"Tamedevelopers\\Database\\Installer::postUpdate"
29-
]
21+
"symfony/console": "^6.0",
22+
"composer-plugin-api": "^2.0"
3023
},
3124
"autoload": {
3225
"files": [
@@ -37,6 +30,9 @@
3730
},
3831
"classmap": ["src/*"]
3932
},
33+
"extra": {
34+
"class": "Tamedevelopers\\Database\\ComposerPlugin"
35+
},
4036
"minimum-stability": "stable",
4137
"prefer-stable": true
4238
}

src/ComposerPlugin.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tamedevelopers\Database;
6+
7+
use Composer\Composer;
8+
use Composer\IO\IOInterface;
9+
use Composer\Plugin\PluginInterface;
10+
use Composer\EventDispatcher\EventSubscriberInterface;
11+
use Composer\Script\ScriptEvents;
12+
13+
final class ComposerPlugin implements PluginInterface, EventSubscriberInterface
14+
{
15+
public function activate(Composer $composer, IOInterface $io): void {}
16+
public function deactivate(Composer $composer, IOInterface $io): void {}
17+
public function uninstall(Composer $composer, IOInterface $io): void {}
18+
19+
public static function getSubscribedEvents(): array
20+
{
21+
return [
22+
ScriptEvents::POST_INSTALL_CMD => 'onPostInstall',
23+
ScriptEvents::POST_UPDATE_CMD => 'onPostUpdate',
24+
];
25+
}
26+
27+
public function onPostInstall(): void
28+
{
29+
// Run package post-install logic
30+
Installer::postInstall();
31+
}
32+
33+
public function onPostUpdate(): void
34+
{
35+
// Run package post-update logic
36+
Installer::postUpdate();
37+
}
38+
}

0 commit comments

Comments
 (0)