Download the PHP package vinou/bot-counter without Composer

On this page you can find all versions of the php package vinou/bot-counter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bot-counter

Bot Counter

Counts crawler visits in a small JSON file. Per bot it keeps a lifetime total plus rolling time windows, by default 7 and 30 days.

Comparing the three numbers says more than any single one:

Pattern Meaning
total ≈ last7days ≈ last30days new bot, just showed up
high total, both windows 0 stopped coming
last7days close to last30days ramping up right now
high total, small last7days steady, low-frequency visitor

No database, no service, no configuration — one file, one call.

Installation

Requires PHP 5.6 or newer. The counter itself has no dependencies.

Usage

That is all. The file is created on first use — its directory has to exist.

With crawler detection

If you use jaybizzle/crawler-detect, the optional adapter detects and counts in one call:

Reading the numbers

read() recalculates the windows, so they are accurate even if nothing has been counted for a while.

The file

Bots are sorted by total, busiest first. days holds one bucket per day and is what the windows are summed from — rolling windows cannot be plain counters, because they have to shrink again. Buckets older than the longest window are dropped on write, so the file does not grow over time.

Options

Notes

Concurrency. Several bots can hit a site in the same moment, so the whole read-modify-write cycle runs under an exclusive lock on a separate .lock file next to the counter. Do not delete that file while the application is running.

An earlier version held a single file handle across the cycle and locked that — it lost counts under load (54 of 60 concurrent requests) because a stream opened before the lock was granted can still serve buffered content afterwards.

Every bot is recalculated on each write, not just the active one. Otherwise a bot that stopped visiting would keep the window values of its last visit forever.

Bot names are treated as input. They usually come from a user agent, so they are lowercased, reduced to [a-z0-9._- ] and capped at 60 characters before becoming a key.

Nothing throws. Every failure — unwritable directory, damaged JSON, full disk — is swallowed and reported through the return value of count(). A damaged file starts over. A counter is never worth a broken page.

It counts requests, not sessions. A crawler fetching ten pages appears ten times.

Caching matters. If a CDN or proxy sits in front of the application, or bots honour your Cache-Control headers, requests never reach PHP and are not counted. The file measures load on your server, which is usually the question anyway.

License

MIT


All versions of bot-counter with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vinou/bot-counter contains the following files

Loading the files please wait ...