0

Usage

After cloning this repository (git clone https://github.com/naneau/php-obfuscator) and installing the dependencies through Composer (composer install), run the following command to obfuscate a directory of PHP files:

Source: https://github.com/naneau/php-obfuscator

I have never used "git", "cloned a repository", and I don't have a GitHub account, nor can I register one. I've used countless libraries by doing "composer install something". I've never had to "clone a repository" for any of those to work.

What does "cloning a repository" mean, and why is it (apparently) required to use this particular library? Also, note that the author doesn't mention what the library is actually called in Composer, which I find extremely strange. (They sometimes have very non-obvious names there.)

0

3 Answers 3

5

Welcome to SuperUser.

Cloning a repository is grabbing all the source files and copying them to your computer so you can work with them. It looks like you're downloading the source files and not a compiled library. You can compile the library yourself if there isn't a download link for it on the GitHub page or in the readme file.

0
4

There is no 'technical' answer to your main question. The only answer is "It's what the project's author decided to put in the README", and unless you go and ask them directly, you will only get answers that try to guess at some unknown person's thought process

Why is this particular library special in that it requires some "git" stuff?

The project's README seems to be written with the standalone bin/obfuscate tool in mind – it's very likely that the author did not plan on it being used as a library at all!

However, it doesn't actually require some "git" stuff; that's just what the project author describes in the README. But you can always download a .zip archive of the files instead. And the project is available through Composer, too, and has had a composer.json file since the beginning.

Also, note that the author doesn't mention what the library is actually called in Composer, which I find extremely strange. (They sometimes have very non-obvious names there.)

It could be that the author assumed you will simply try the same name as in the GitHub address, i.e. naneau/php-obfuscator, or that you will find the name by reading the project's "composer.json" file. I think it is perfectly reasonable to assume that it will have an obvious name by default.

That being said, not all projects are automagically available through Composer – to make that happen, the author needs to register for a Packagist.org account and publish each project there first. Not being published is not actually 'special', it is the default state.

So in the general case, there is nothing very unusual about such a situation. Maybe the (hypothetical) developer just doesn't care about Composer, or is even not aware that it exists. Maybe the developer considers the project mainly as a command-line tool rather than a library dependency. Maybe the developer prioritizes Git because the project is under heavy development and is not in a state to have "releases". Maybe the developer, like you, doesn't have a Packagist account nor can register one.

What does "cloning a repository" mean

Roughly, it is similar to downloading the project's files as a .zip or .tar.gz archive.

As Git is a version-control tool (i.e. meant to track changes to code over time), the difference of using git clone to download its repository is that you'll immediately have all versions at hand. By default it will also give you the very latest "development" version, which has had a few changes since the 0.0.5 release happened.

I have never used "git", "cloned a repository",

It is perhaps time to start doing so. In general, although using Git is not mandatory (Hg aka Mercurial and SVN are two most common alternatives), using some kind of "version control system" is probably Item #1 of best practices when programming in any language, for any platform.

You'll find that most libraries and other projects are hosted as a Git repository, and Composer often uses Git "behind the scenes".

and I don't have a GitHub account, nor can I register one

There is a distinction between using Git and using GitHub. The former is a tool, the latter is a hosting provider. One can use Git without having a GitHub account, much like one can program in PHP without having a web-hosting account.

In any case, accounts are not required in order to download something from GitHub – certainly not for a publicly accessible repository.

1

What does "cloning a repository" mean, and why is it (apparently) required to use this particular library?

Git is a tool for version control. That is, a program author uses it to manage (add/remove/update) the source code files of a program (in this case, the actual PHP files used in the script).

As already detailed in the other answers to this question, "cloning" is a git term for copying source files (PHP files) to a PC. This may be so others can modify the source code as well and then use git to update the files on e.g. GitHub with those changes, or it can be used to simply "distribute" whatever files are currently available.

Unlike programs similar to Composer, git simply copies files to or from a destination. It isn't intended to do any dependency checking, etc.

Also, note that the author doesn't mention what the library is actually called in Composer, which I find extremely strange. (They sometimes have very non-obvious names there.)

Looking at composer.json file in the main repository, it looks like the name may be php-obfuscator.

I would also assume that the composer install command would be run from the same directory, so Composer might automatically detect composer.json.

I'm asking why the git step exists at all.

Because the author expects that other people may choose to use that tool to download the source files to their computers, rather than downloading the files manually.

What does that have to do with using the library?

Nothing, other than copying the files to the PC.

Why is this particular library special in that it requires some "git" stuff?

The library isn't special and the git step isn't required. You can click the big green "Clone or download" button and select the "Download ZIP" option to simply download the repository as a zip file if you like.

I have never used "git", "cloned a repository", and I don't have a GitHub account, nor can I register one.

As mentioned above, simply download the zipped version of the repository. You don't need an account to do this.

2
  • 1
    You don't need an account for git clone either (unless you go out of your way to use the SSH URL instead of the HTTPS one).
    – user1686
    Mar 9, 2020 at 7:29
  • Excellent point. Mar 9, 2020 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.