Skip to content

Commit

Permalink
composer post install script
Browse files Browse the repository at this point in the history
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
  • Loading branch information
MarioRadu committed Dec 4, 2024
1 parent 073392c commit 06a8ec3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions bin/composer-post-install-script.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols

function copyFile(array $file): void
{
if (is_readable($file['destination'])) {
echo "File {$file['destination']} already exists." . PHP_EOL;
} else {
if (! copy($file['source'], $file['destination'])) {
echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL;
} else {
echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL;
}
}
}

$files = [
[
'source' => 'config/autoload/local.php.dist',
'destination' => 'config/autoload/local.php',
],
];

array_walk($files, 'copyFile');
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
"post-create-project-cmd": [
"@development-enable"
],
"post-update-cmd": [
"php bin/composer-post-install-script.php"
],
"development-disable": "laminas-development-mode disable",
"development-enable": "laminas-development-mode enable",
"development-status": "laminas-development-mode status",
Expand Down

0 comments on commit 06a8ec3

Please sign in to comment.