update
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "nightmare/php-composer-plugin",
|
||||||
|
"description": "php plugin for composer",
|
||||||
|
"type": "composer-plugin",
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.4",
|
||||||
|
"composer-plugin-api": "^2.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Nightmare\\ComposerPlugin\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"class": "Nightmare\\ComposerPlugin\\ComposerPlugin"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Nightmare\ComposerPlugin;
|
||||||
|
|
||||||
|
use Composer\Plugin\PluginInterface;
|
||||||
|
use Composer\EventDispatcher\EventSubscriberInterface;
|
||||||
|
use Composer\Installer\PackageEvent;
|
||||||
|
use Composer\Script\Event;
|
||||||
|
|
||||||
|
class ComposerPlugin implements PluginInterface, EventSubscriberInterface
|
||||||
|
{
|
||||||
|
public function activate(\Composer\Composer $composer, \Composer\IO\IOInterface $io) {}
|
||||||
|
public function deactivate(\Composer\Composer $composer, \Composer\IO\IOInterface $io) {}
|
||||||
|
public function uninstall(\Composer\Composer $composer, \Composer\IO\IOInterface $io) {}
|
||||||
|
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'post-install-cmd' => 'create_htaccess',
|
||||||
|
'post-update-cmd' => 'create_htaccess'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create_htaccess(Event $event)
|
||||||
|
{
|
||||||
|
$vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');
|
||||||
|
$htaccess_path = $vendor_dir . '/.htaccess';
|
||||||
|
$content = "Require all denied";
|
||||||
|
|
||||||
|
file_put_contents($htaccess_path, $content);
|
||||||
|
$event->getIO()->write("<info>created .htaccess in $vendor_dir</info>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user