https://github.com/rvalitov/backlink-checker-php
Validates a predefined list of backlinks on remote websites that they exist and are correct (for SEO). Simple and Javascript-enabled web engines are used for scraping.
https://github.com/rvalitov/backlink-checker-php
backlinks seo seo-tools seotools
Last synced: about 1 month ago
JSON representation
Validates a predefined list of backlinks on remote websites that they exist and are correct (for SEO). Simple and Javascript-enabled web engines are used for scraping.
- Host: GitHub
- URL: https://github.com/rvalitov/backlink-checker-php
- Owner: rvalitov
- License: gpl-3.0
- Created: 2018-10-13T10:16:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-11-15T10:44:04.000Z (about 2 months ago)
- Last Synced: 2025-11-27T16:27:26.005Z (about 2 months ago)
- Topics: backlinks, seo, seo-tools, seotools
- Language: PHP
- Size: 495 KB
- Stars: 57
- Watchers: 3
- Forks: 19
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Backlink Validator for SEO




[](https://app.codacy.com/gh/rvalitov/backlink-checker-php/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
[](https://app.codacy.com/gh/rvalitov/backlink-checker-php/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php)
[](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php)
[](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php)
[](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php)
[](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php)
[](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php)
[](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php)
[](https://github.com/rvalitov/backlink-checker-php/actions/workflows/tests.yml)


This project is a package for developers to validate backlinks in SEO.
Unlike other tools that scan the Internet or analyze Google Search results to find backlinks,
our tool focuses exclusively on verifying backlinks from a list you already have.
You might get this list of backlinks through:
* **Purchasing backlinks**: Receiving a list of donor web pages from the seller or backlinks market.
* **Creating backlinks yourself**: Posting on forums, third-party websites, or other platforms.
* **SEO service providers**: your SEO expert or company shares a reports with backlinks as one of the SEO strategies.
Once you have a list of donor web pages, it's crucial to confirm that the backlinks are present and functional.
Moreover, ongoing validation is necessary to ensure the backlinks remain active and haven’t been removed over time.
This package simplifies backlink checking and verification by:
* Verifying the presence of fixed backlinks, such as `https://example.com`.
* Supporting powerful search patterns, like `*.example.com`, using
[regular expressions](https://en.wikipedia.org/wiki/Regular_expression) defined by you.
With this package, monitoring and maintaining your backlinks becomes efficient and hassle-free.
## Browser Scraping Modes
### Simple
Pros:
* **Fast**: Simple mode is faster.
* **Low resource consumption**: Simple mode uses fewer resources.
* **Minimal dependencies**: Simple mode requires fewer dependencies.
* **Shared hosting**: Simple mode works on shared hosting.
Cons:
* **No JavaScript**: Simple mode does not support JavaScript,
so it works only for simple or static HTML, for example, generated by Joomla, WordPress or Drupal.
It will not find backlinks on websites that require JavaScript-enabled browser,
for example, websites made with Laravel, Yii, React, etc.
### Chromium
The [Chromium headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome) is used
for JavaScript-enabled browsing.
This approach allows parsing any website, and this is the universal mode,
but it uses more resources on the server and requires a little bit more time to configure the server.
Pros:
* **Universal**: Chromium mode supports JavaScript, so it can parse any website.
Cons:
* **Slower**: Chromium mode is slower.
* **Higher resource consumption**: Chromium mode uses more resources.
* **Advanced hosting plan**: requires a VPS or dedicated server, does not work on shared hosting.
## How to Install
### Step 1. Add the Package via Composer
You must have a [Composer](https://getcomposer.org/) installed.
Run the following command:
```bash
php composer require rvalitov/backlink-checker-php
```
Required PHP extensions:
* [`json`](https://www.php.net/manual/en/json.installation.php)
* [`sockets`](https://www.php.net/manual/en/sockets.installation.php)
### Step 2. Install the Chromium
**Note:** You can skip this step if you don't need the Chromium mode.
You need to install the following packages first, to make the Chromium work.
**For Debian/Ubuntu:**
```bash
apt-get update
apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
```
You must have a [Node.js](https://nodejs.org/) installed.
If it's not installed, install it using the official manual.
If you use PHP 8.0 or later, you need to install the following package:
```bash
npm install https://github.com/zoonru/rialto
```
If you use PHP 7.4, you need to install the following package:
```bash
npm install @nesk/rialto
```
### Step 3. Use Autoload
Include the `autoload.php` in your source PHP file, for example:
```php
getBacklinks($url, $pattern, $scanBacklinks, $scanHotlinks, $makeScreenshot);
} catch (\Exception $e) {
die("Error: " . $e->getMessage());
}
```
The function `getBacklinks` has the following additional options:
* `$scanBacklinks` - if set to `true`,
then it scans for the backlinks
(the text of the `href` attribute of [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) tag);
otherwise scanning is not performed.
* `$scanHotlinks` - if set to `true`, then it scans for the [hotlink](https://simple.wikipedia.org/wiki/Hotlinking) (the
text of the `src` attribute of [`
`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) tag);
otherwise scanning is not performed.
* `$makeScreenshot` - if set to `true`, then we also take a screenshot of the viewport; otherwise screenshot is not
made.
This option makes sense only for Chromium mode (default viewport size is `800 x 600` px, image format: `JPEG`,
image quality: `90`, image encoding: `binary`); for simple mode this option is ignored.
Now we should check the `$result`, if the function succeeded:
```php
$response = $result->getResponse();
if ($response->isSuccess()) {
$links = $result->getBacklinks();
if (sizeof($links) > 0)
//Backlinks found
else {
//No backlinks found
}
} else {
//Error, usually network error, or server error
die("Error, HTTP Code " . $response->getStatusCode());
}
```
The function `$result->getBacklinks()` returns an array of objects that describe the backlink. Each object supports the
following functions:
* `getBacklink` returns `string`, a backlink - an exact URL that matches the target domain;
* `getTag` returns `string`, the tag that is used for the backlink, can be `a` or `img`;
* `getTarget` returns `string`, contents of
[`target`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/A#attr-target) attribute of the `href`;
* `getNoFollow` returns `true` if the backlink has [`nofollow`](https://en.wikipedia.org/wiki/Nofollow) attribute;
* `getAnchor` returns `string` - anchor of the link, for example, inner text of `` tag. This text is returned in a
plain text format, all HTML tags are stripped.
The `$response` object supports the following functions:
* `getUrl` returns `string`, the URL of that was analyzed
* `getStatusCode` returns `int`, the [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes), or `0`
or `-1` if there was a network error.
* `getScreenshot` returns `string`, the screenshot in binary format. If the screenshot was not taken or is not
available, then the string is empty. If you want to display this screenshot as an image on a web page, then you should
first save it to disk and use a link to it, or encode it into [base64](https://en.wikipedia.org/wiki/Data_URI_scheme)
and insert into the web page directly. In this case, you can use a function like:
```php
$base64_image = "data:image/jpeg;base64," . base64_encode($response->getScreenshot());
```
**Note**. If you use function [`json_encode`](http://php.net/manual/en/function.json-encode.php) on an object that
contains the screenshot, then this screenshot will be converted
to [base64](https://en.wikipedia.org/wiki/Data_URI_scheme) format automatically.
## Examples
Examples are available in a dedicated project on [GitHub](https://github.com/rvalitov/backlink-checker-php-demo).
Tests are in `tests` folder.