avolle/cakephp-deadlinks

CakePHP Plugin to search database entries for dead links

Installs: 552

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 1

Type:cakephp-plugin

2.0.0 2023-10-15 22:08 UTC

This package is auto-updated.

Last update: 2024-10-16 00:21:51 UTC


README

Deadlinks CI

Scan links inside your database records to make sure they're not dead.

The links you once inserted into your database may not work in the future. This plugin makes sure all your links are well and alive. If any links are found to be dead, the results can be ouput through various methods.

Output methods:

  • Terminal
  • Log file
  • Mail

Version map:

Installation

composer require avolle/cakephp-deadlinks

Usage

Add a config file in your app config folder, describing which tables and fields to scan. Optionally you can insert an email recipient to receive results when selecting the mail ouput method.

Example config file (/config/deadlinks.php): This config file will scan the following tables and fields:

  • Files
    • linkOne
    • linkTwo
  • Links
    • link
  • Resources
    • link
<?php

return [
    'Deadlinks' => [
        /*
         * Mail Recipient. Person to receive results when mail output is selected
         */
        'mailRecipient' => 'cakephp-plugins@avolle.com',

        /*
         * Tables to scan and their fields
         */
        'tables' => [
            'Files' => [
                'fields' => [
                    'linkOne',
                    'linkTwo',
                ],
            ],
            'Links' => [
                'fields' => [
                    'link',
                ],
            ],
            'Resources' => [
                'fields' => [
                    'link',
                ],
            ],
        ],
    ],
];

Add the plugin in your src/Application.php file. Put it inside the bootstrapCli method

protected function bootstrapCli(): void
{
    $this->addPlugin('Avolle/Deadlinks');
}

To run the scanner, execute this command in your terminal

  • Output in terminal: bin\cake scan -t
  • Output to log file: bin\cake scan -l
  • Output to an email: bin\cake scan -m

You can also ouput several methods. For both terminal and log file, run bin\cake scan -t -l.

For help, run bin\cake scan -h