49 lines
1.1 KiB
Markdown
49 lines
1.1 KiB
Markdown
Similar project to [spatie/http-status-check](https://github.com/spatie/http-status-check) but this will collect ALL the found on URL's (not just first occurrence) and return the results as an array for further processing in your own application (no console command).
|
|
|
|
## Install
|
|
|
|
```plain
|
|
composer config repositories.jhodges composer https://composer.jhodges.co.uk/
|
|
composer require jhodges/sitemap
|
|
```
|
|
|
|
## Usage
|
|
Note: start the test server as shown below if you want to use the localhost:8080 site as per usage example.
|
|
|
|
```php
|
|
use \JHodges\Sitemap\Crawler;
|
|
|
|
$crawler=new Crawler();
|
|
$crawler->crawl('https://localhost:8080');
|
|
$sitemap=$crawler->getResults();
|
|
print_r($sitemap);
|
|
```
|
|
|
|
To crawl multiple areas of the same site that are not interlinked, you may:
|
|
|
|
```php
|
|
use \JHodges\Sitemap\Crawler;
|
|
|
|
$crawler=new Crawler();
|
|
$crawler->crawl('https://localhost:8080/interlinked1');
|
|
$crawler->crawl('https://localhost:8080/deeplinked1');
|
|
$sitemap=$crawler->getResults();
|
|
print_r($sitemap);
|
|
```
|
|
|
|
## Tests
|
|
|
|
Start the test server, will listen on localhost:8080
|
|
|
|
```plain
|
|
cd tests/server
|
|
npm install
|
|
node server.js
|
|
```
|
|
|
|
Run the tests:
|
|
|
|
```plain
|
|
vendor/bin/phpunit tests
|
|
```
|