Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added generate sitemap command + schedule option #2

Merged
merged 22 commits into from
Dec 6, 2024

Conversation

kevinmeijer97
Copy link
Member

Added the possibility to generate (or pre-cache) the sitemaps with the ability to also hook into the generation command by using an Eventy action.

README.md Outdated
Comment on lines 18 to 34
## Sitemap Generation
This package includes a configuration option to control the automatic scheduling of the sitemap generation command.

In the package’s service provider, if `schedule_generate_command` is enabled, the command is scheduled:

```php
if (config('rapidez.sitemap.schedule_generate_command')) {
Schedule::command('rapidez:sitemap:generate')->twiceDaily(0, 12);
}
```

To disable scheduling, set this in your .env: `RAPIDEZ_SITEMAP_SCHEDULE_GENERATE=false`.

To run the sitemap generation manually, use:
```bash
php artisan rapidez:sitemap:generate
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure if we want this within the package. From rapidez/core we're not registering any schedules, for example for the indexer: https://docs.rapidez.io/3.x/indexer.html#scheduler and that's moved with Laravel 11 to routes/console.php or the bootstrap/app.php, maybe we should provide some examples within rapidez/rapidez which you can simply uncomment and change?

I'm afraid if we're going to register schedules from packages users aren't aware of them, there is a schedule:list command but still; better to have them defined within your project in 1 place? And mention that in the configuration or deployment docs.

Thoughts @kevinmeijer97 / @indykoning / @BobWez98?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we're not doing it for other commands either, and you will always lack control by registering it automatically.
(Like, when do you want it executed? Do you want to run it in your own cronjob so you can separate command output?)

I agree it might be better to make users register it manually so they have maximum control.
That way they could even execute it on events and not based on cron at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, i removed the scheduling and added some info in the readme for this

README.md Outdated Show resolved Hide resolved
@kevinmeijer97 kevinmeijer97 requested a review from royduin December 5, 2024 16:01
@royduin
Copy link
Member

royduin commented Dec 5, 2024

With this approach the sitemap will be cleared with a cache clear; maybe better to actually generate the sitemap and get rid of the controller?

@kevinmeijer97
Copy link
Member Author

kevinmeijer97 commented Dec 6, 2024

With this approach the sitemap will be cleared with a cache clear; maybe better to actually generate the sitemap and get rid of the controller?

I agree, this has now been changed to work as follows:
The SitemapController only points you to the right sitemap.xml based on your current store.
The sitemap.xml files are generated for each store after running the GenerateSitemap command.
These are put in their respective folders inside the public storage in /rapidez-sitemaps/{store_id}/sitemap.xml

@royduin royduin merged commit f82c36e into master Dec 6, 2024
10 checks passed
@royduin royduin deleted the feature/sitemap-generate branch December 6, 2024 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants