As a side project, I want to create a package manager for PHP using Github repositories.
When I run my command:
absol pickup <git-repo>
Under the hood, I run the command with shell_exec
:
shell_exec("git clone -q --depth=1 $git_repo $path");
And all works as expected.
Problem:
Now I’m trying to implement a command that will let me delete unwanted packages. When I try to delete files with the unlink
function I get the error:
Warning: unlink(.gitobjectspackpack-83ff79c801011289eaee13a84795a6288641feec.idx): Permission denied
Is there a way to delete these files using PHP on Windows?
P.S. This is just a personal side project as a utility for more side projects. I’m fine with deleting packages manually if this problem cannot be resolved.
2
Answers
Ansh answer is not entirely correct, but it gave me a push to the right answer:
Removed normal file (
README.md
) but the.git
directory was still intact and this question focuses on removing the.git
directory.This command worked, but I have modified it to delete the whole package directory.
Since you’re dealing with Git-related files, consider using Git commands to delete the files. You can execute Git commands from PHP using shell_exec or other similar functions. For example-
As a last resort, you can use the cmd.exe command prompt to delete the files. Use shell_exec to run the del command-