Skip to content

Dantleech/Fink link checker

Fink is a command line tool for checking HTTP links written in PHP. It's checks websites for broken links or error pages.

Learn by example

Check out our example Fink repository.

How to install Fink

There are two options to install Fink. You can do it as a stand-alone tool with the command:

$ composer require dantleech/fink --dev

Or you can Download the PHAR from the Fink release page

Use Fink

For crawling a single URL run this command:

$ ./vendor/bin/fink https://www.example.com

To create a json report for each URL use --output=fileName.json

For more information and options go to the Fink github.

Set up Fink in Gitlab

  • To set up a Fink CI in Gitlab you will need a Gitlab account and a Gitlab project.

Gitlab project

  • You will also need a Gitlab personal access token.

    • You can create your access token by clicking on your avatar in the upper-right corner and select Settings
    • Click on Access Tokens in the left menu
    • Choose a name and optional expiry date for the token
    • For scope select API
    • Click the Create personal access token button
    • Once you leave or refresh the page, you won’t be able to see your token again so copy it somewhere save
    • For more information on access tokens, please visit the official Gitlab documentation on access tokens.
  • To push your result to Calliope you will need an account on Calliope.pro too.

  • Create a new .gitlab-ci.yml file in the root of your project, copy the example gitlab job from below and update the following with your own values:

    API_KEY (your Calliope API key)

    HOME_URL (the website you want to have scanned)

    PROFILE_ID (the Calliope profile ID)

  • Save the .gitlab-ci file and start a testrun

  • Link the Calliope project with the gitlab job (see: Calliope GitLab Integration )

Example

run-link-checker:
    image: spritecloud/linkchecker
    variables:
      API_KEY: <YOUR_API_KEY>
      HOME_URL: "https://www.spritecloud.com"
      PROFILE_ID: <YOUR_PROFILE_ID>
    before_script:
      - export PATH="$PATH:/usr/src/app/vendor/bin"
    script:
      - fink $HOME_URL --output=result.json --max-external-distance=0 --max-distance=2 --exclude-url=https://www.spritecloud.com/feed
    after_script:
      - curl -X POST -H "x-api-key:$API_KEY" -H "Content-Type:multipart/form-data" -F "file[]=@result.json" https://app.calliope.pro/api/v2/profile/$PROFILE_ID/import/fink
    cache:
      paths:
        - .json
    when: manual