|
| 1 | +# Laravel Package for testing Schema.org markup or other structured data formats with google structured data testing tool undocumented API. |
| 2 | + |
| 3 | +[](https://packagist.org/packages/padosoft/laravel-google-structured-data-testing-tool) |
| 4 | +[](LICENSE.md) |
| 5 | +[](https://travis-ci.org/padosoft/laravel-google-structured-data-testing-tool) |
| 6 | +[](https://scrutinizer-ci.com/g/padosoft/laravel-google-structured-data-testing-tool) |
| 7 | +[](https://packagist.org/packages/padosoft/laravel-google-structured-data-testing-tool) |
| 8 | +[](https://insight.sensiolabs.com/projects/9482504c-ed2d-423f-94bb-1cf3a6babff0) |
| 9 | + |
| 10 | +This package provides a series of commands to automate and bulk check of Schema.org markup or other structured data formats with google structured data testing tool undocumented API that I found. |
| 11 | +Google already provides a good tool for testing markup data using the Search Console in Webmaster Tools. |
| 12 | +But how can I test markup data if you want to programmatically test your web site urls or a bulk set of urls? |
| 13 | +You can't do this with google wmt. |
| 14 | +This package try to resolve these problems. |
| 15 | + |
| 16 | +## WARNING |
| 17 | +Note: This is an undocumented Google API. I found it when I interacted with Google’s Structured Data Testing Tool and Google Chrome debug console, |
| 18 | + thus there is no warranty that the API remains public or that the API changes make the package unusable. |
| 19 | + |
| 20 | +##Requires |
| 21 | + |
| 22 | +- php: >=7.0.0 |
| 23 | +- illuminate/support: ^5.0 |
| 24 | +- illuminate/http: ^5.0 |
| 25 | +- padosoft/support": ^1.9 |
| 26 | + |
| 27 | +## Installation |
| 28 | + |
| 29 | +You can install the package via composer: |
| 30 | +``` bash |
| 31 | +$ composer require padosoft/laravel-google-structured-data-testing-tool |
| 32 | +``` |
| 33 | +You must install this service provider. |
| 34 | + |
| 35 | +``` php |
| 36 | +// config/app.php |
| 37 | +'provider' => [ |
| 38 | + ... |
| 39 | + Padosoft\Laravel\Google\StructuredDataTestingTool\GoogleStructuredDataTestToolServiceProvider::class, |
| 40 | + ... |
| 41 | +]; |
| 42 | +``` |
| 43 | +You don't need to register the command in app/Console/Kernel.php, because it provides by GoogleStructuredDataTestToolServiceProvider register() method. |
| 44 | + |
| 45 | +You can publish the config file of this package with this command: |
| 46 | +``` bash |
| 47 | +php artisan vendor:publish --provider="Padosoft\Laravel\Google\StructuredDataTestingTool\GoogleStructuredDataTestToolServiceProvider" |
| 48 | +``` |
| 49 | +The following config file will be published in `config/laravel-google-structured-data-testing-tool.php` |
| 50 | +``` php |
| 51 | +return array( |
| 52 | + 'mailSubjectSuccess' => env( |
| 53 | + 'STRUCTURED_DATA_TESTING_TOOL_SUBJECT_SUCCESS', |
| 54 | + '[google-structured-data-testing-tool]: Ok - markup data is ok.' |
| 55 | + ), |
| 56 | + 'mailSubjetcAlarm' => env( |
| 57 | + 'STRUCTURED_DATA_TESTING_TOOL_SUBJECT_ALARM', |
| 58 | + '[google-structured-data-testing-tool]: Alarm - markup data error detected.' |
| 59 | + ), |
| 60 | + 'mailFrom' => env('STRUCTURED_DATA_TESTING_TOOL_MESSAGE_FROM', ' [email protected]'), |
| 61 | + 'mailFromName' => env('STRUCTURED_DATA_TESTING_TOOL_MESSAGE_FROM_NAME', 'Info Example'), |
| 62 | + 'mailViewName' => env('STRUCTURED_DATA_TESTING_TOOL_MAIL_VIEW_NAME', 'laravel-google-structured-data-testing-tool::mail'), |
| 63 | + 'logFilePath' => env('STRUCTURED_DATA_TESTING_TOOL_LOG_FILE_PATH', storage_path() . '/logs/laravel-google-structured-data-testing-tool.log') |
| 64 | +); |
| 65 | +``` |
| 66 | + |
| 67 | +In your app config folder you can copy from src/config/.env.example the settings for yours .env file used in laravel-google-structured-data-testing-tool.php. |
| 68 | +If you use mathiasgrimm/laravel-env-validator |
| 69 | +in src/config folder you'll find an example for validate the env settings. |
| 70 | + |
| 71 | + |
| 72 | +## USAGE |
| 73 | + |
| 74 | +When the installation is done you can easily run command to print help: |
| 75 | +```bash |
| 76 | +php artisan google-markup:test https://www.padosoft.com |
| 77 | +``` |
| 78 | + |
| 79 | +The `google-markup:test` command check the structured data and schema.org markup in the given site https://www.padosoft.com |
| 80 | + |
| 81 | +You can also pass the path of url txt (a file with one url per line) as an argument: |
| 82 | +`php google-markup:test /path/to/my/url.txt` |
| 83 | +so you can check multiple site/url (bulk) in one command! |
| 84 | + |
| 85 | +By default, the command displays the result in console, but you can also |
| 86 | +send an html email by using the `--mail`option: |
| 87 | +```bash |
| 88 | +php google-markup:test https://www.padosoft.com [email protected] |
| 89 | +``` |
| 90 | +### EXAMPLE: |
| 91 | + |
| 92 | +Here is a basic example to check composer.lock into these dir: |
| 93 | +```bash |
| 94 | +php artisan google-markup:test https://www.padosoft.com |
| 95 | +``` |
| 96 | +Here is an example to send output report to mail: |
| 97 | +```bash |
| 98 | +php artisan google-markup:test https://www.padosoft.com --mail=mymail@mydomain |
| 99 | +``` |
| 100 | +Here is an example to ignore two urls for markup error (if command found any markup error into these dir, write it into output but the email subject isn't set to ALERT): |
| 101 | +```bash |
| 102 | +php artisan google-markup:test /path/to/my/url.txt --mail=mymail@mydomain --whitelist="https://www.padosoft.com,https://blog.padosoft.it" |
| 103 | +``` |
| 104 | + |
| 105 | +## SCHEDULE COMMAND |
| 106 | + |
| 107 | +You can schedule a daily (or weekly etc..) report easly, by adding this line into `schedule` method in `app/Console/Kernel.php` : |
| 108 | +```php |
| 109 | +// app/console/Kernel.php |
| 110 | + |
| 111 | +protected function schedule(Schedule $schedule) |
| 112 | +{ |
| 113 | + ... |
| 114 | + $schedule->command('google-markup:test "/path/to/my/url.txt" --mail=mymail@mydomain') |
| 115 | + ->daily() |
| 116 | + ->withoutOverlapping() |
| 117 | + ->sendOutputTo(Config::get('laravel-google-structured-data-testing-tool.logFilePath')); |
| 118 | +} |
| 119 | +``` |
| 120 | + |
| 121 | +## SCREENSHOOTS |
| 122 | + |
| 123 | +OUTPUT CONSOLE WITH ONE URL TEST: |
| 124 | + |
| 125 | + |
| 126 | +OUTPUT CONSOLE BULK CHECK OK: |
| 127 | + |
| 128 | + |
| 129 | +OUTPUT CONSOLE BULK CHECK WITH ERRORS: |
| 130 | + |
| 131 | + |
| 132 | +EMAIL VIEW: |
| 133 | + |
| 134 | + |
| 135 | +EMAIL VIEW WITH ERRORS: |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | +## Change log |
| 140 | + |
| 141 | +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. |
| 142 | + |
| 143 | +## Testing |
| 144 | + |
| 145 | +``` bash |
| 146 | +$ composer test |
| 147 | +``` |
| 148 | + |
| 149 | +## Contributing |
| 150 | + |
| 151 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
| 152 | + |
| 153 | +## Security |
| 154 | + |
| 155 | +If you discover any security related issues, please email instead of using the issue tracker. |
| 156 | + |
| 157 | +## Credits |
| 158 | +- [Lorenzo Padovani](https://github.com/lopadova) |
| 159 | +- [All Contributors](../../contributors) |
| 160 | + |
| 161 | +## About Padosoft |
| 162 | +Padosoft (https://www.padosoft.com) is a software house based in Florence, Italy. Specialized in E-commerce and web sites. |
| 163 | + |
| 164 | +## License |
| 165 | + |
| 166 | +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
0 commit comments