Download the PHP package laravel-freelancer-nl/laravel-index-now without Composer
On this page you can find all versions of the php package laravel-freelancer-nl/laravel-index-now. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravel-freelancer-nl/laravel-index-now
More information about laravel-freelancer-nl/laravel-index-now
Files in laravel-freelancer-nl/laravel-index-now
Package laravel-index-now
Short Description Alert search engines of content changes.
License MIT
Homepage https://github.com/LaravelFreelancerNL/laravel-index-now
Informations about the package laravel-index-now
Laravel IndexNow - Submit webpage updates to search engines
This packages provides a wrapper to use the IndexNow api in Laravel. This makes indexing new webpages in (some) search engines easy and fast. It makes for a nice little addition to sitemaps.
IndexNow is an API created by Microsoft Bing & Yandex to allow you to submit page changes to their search engines quickly. A submission to one search engine will automatically pass the submission on to the others.
At the time of this writing Google is considering supporting the API and has announced it will be testing it.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
- host: the domain for which you will submit pages to the search engine
- key: the unique key for this domain (you will generate one in the next step)
- key-location: the directory and/or prefix to the key file
- log-failed-submits: disable logging of submit attempts in non-production environments
- production-env: the name of the production environment;
- search-engine: the domain of the specific search engine you wish to submit too.
- delay: the delay in seconds for delayed page submissions.
Generate a new key
The IndexNow API matches the request key to a key file within the host domain. To generate the keyfile you use the following artisan command:
This will create a keyfile in the public_dir() of your project and output the key. Copy the displayed key and place it in your .env file.
If you've set a key location in the config it will be prefixed to the file.
Running this command multiple times will generate a new key and key file.
Only submit pages for your production environment
You probably don't want to submit pages in any environment other than production.
By default, this package assumes that your production environment is called 'production' and will only submit when it matches the configured name in the package.
In the case of an environment mismatch it will log a submission 'attempt' instead of actually submitting the page to the search engines.
If you use an alternative name for your production environment you can set INDEXNOW_PRODUCTION_ENV in your .env to match.
You can disable this by setting INDEXNOW_PRODUCTION_ENV to false.
Usage
You can submit one or more pages per request by calling the facade and passing the url(s) to the submit method.
Note that the urls must be fully qualified without query parameters and without a fragment.
Submit a single page
Submit a multiple pages
To submit multiple pages at once just add an array of urls.
Prevent spam: delay page submissions
You can delay page submissions by using the delaySubmission method. This dispatches the IndexNowSubmitJob with a delay in seconds as configured. The job is unique by payload, so multiple submissions of the same urls won't push a job to the queue before the current one is handled.
You can override the configured default delay by adding your own.
When to delay submits
It isn't uncommon for people to make additional edits after creating or updating a page. On these actions it is a good idea to delay the submission.
When deleting pages you can just submit the urls immediately.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Bas
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-index-now with dependencies
guzzlehttp/guzzle Version ^7.4
illuminate/contracts Version ^9.0|^10.0|^11.0
nunomaduro/termwind Version ^1.10|^2.0
spatie/laravel-package-tools Version ^1.9.2