danack / sitetool
Event based site tool and tester.
Requires
- php: ^7
- alom/graphviz: ~1.1
- amphp/artax: ~3.0.14
- danack/aurynconfig: ^0.9.1
- danack/console: ~2.6
- danack/tier: ^0.7.1
- fluentdom/fluentdom: ~5.3
- rdlowrey/auryn: ^1.4.0
- zendframework/zend-eventmanager: ^3.0
Requires (Dev)
- mockery/mockery: 1.0
- nikic/fast-route: 0.3.0
- phpunit/phpunit: 6.4.4
- room11/caching: ^0.0.4
- room11/http: ^0.2.0
- squizlabs/php_codesniffer: ^2.8
- yoast/yoastcs: 0.4.2
This package is auto-updated.
Last update: 2023-01-12 00:13:15 UTC
README
A couple of very simple tools for checking sites and site migration.
Site crawler
Crawls a site to find all links, and then fetches them. Run with:
php cli.php site:crawl http://phpimagick.com/
Reults by default will be written to 'crawl_result.txt'.
Migration checker
Once a site has been crawled, then you can check to see if the same paths are available on a different domain.
php -d memory_limit=1280M src/cli.php site:migratecheck phpimagick.com www.phpimagick.com
This allows you to check that migrating to a new platform hasn't lost any paths.
Visualizing events
As the whole application is tied together using events, it can be difficult to comprehend how the different parts of the app fit together.
Appending --graph
to any of the commands will make the application generate a graph of how the events + processors are tied together for that command, rather than running the command.
The graph generation depends on having graphviz available. There is a docker composer file for this project to allow generating graphs inside that, which can be invoked with something like.
docker-compose up --build
docker exec sitetool_php_1 php cli.php site:crawl http://phpimagick.com/ --graph
If the project is not checked out to a directory named 'sitetool' you may need to run docker ps
to find the exact docker image name.
Naming things
Event names
Event names should be a past tense phrase that described what has happened. Examples:
FoundUrl
FoundUrlToFetch
FoundUrlToSkip
ReceivedHtml
ResponseWasOk
ResponseWasError
ResponseWasReceived
Processor names
Processor names should be of the form 'verb' + 'object' or 'verb' + 'object' + 'condition'. If possible use the event name as the object.
CheckResponseContentTypeIsHtml CheckResponseIsOk FetchUrl LogResponseWasOk LogResponseWasError LogFoundUrlToSkip ParseReceivedHtmlToFindUrls DecideFoundUrlShouldBeFollowed
Where it makes sense, use the event name that is being listened for, in the procesor name.
php phpstan.phar analyze -c ./phpstan.neon -l 7 src