-
Notifications
You must be signed in to change notification settings - Fork 8
CLI usage #4
Comments
I've written a proof-of-concept CLI for this plugin. It's separated from the kirby CLI and pretty rough, but seems to work fine overall. The fork also adds support to build additional routes (needed to build sitemap.xml in my case) along with domain URL replacement. The latter is a quick and dirty search and replace to avoid uploading the built content to a separate host. All changes needs polish or re-thinking, but I figured I'd share it here in case anyone found it interesting. |
Thanks for sharing, @mogelbrod. I don’t know much about CLI usage for PHP scripts so if I decide to implement it separately I’ll probably use some of your code. Alternatively if you’d like to contribute an implementation that could be great, but I think I might have a few requirements like not adding to the Builder class if it’s not necessary, and perhaps making a I opened issues for the two other topics you mentioned:
I don’t have much experience with managing an open-source project, however small, but if by chance you’d like to be a direct contributor that could be great. Tell me if you’re interested. |
It was my first time writing a PHP CLI script as well as the first time in years I wrote something in PHP, so the code might not be idiomatic PHP :) I'll happily take a look at any issues/possible improvements with the CLI script you can find. The ones I've thought of are:
I would love some feedback regarding these points, along with any additional issues you've got. I'll send a PR for the CLI if/when all required things are fixed. In any case I'll keep working on my fork (will be used to deploy a static site at work), so feel free to grab any code you find useful :) |
You and me both. 😁 Agreed for the template part. For the script name I wonder if it would be possible to call Headers already sent: maybe that's because you run
Argument parsing: if at some point we can reimplement on top of Kirby's cli (which uses some good PHP libs for console stuff), it won't be a problem. In the meantime, I'd keep things simple. For the path to Kirby's bootstrap.php, maybe it should default to To be consistent with the HTTP version, maybe the script should run in dry-run mode by default, and require a specific flag or command to actually write files? Finally, when building several pages, you could use |
Script name: PHP unfortunately outputs the shebang in the browser, so using the same file as entrypoint for both CLI and browser isn't possible unless dropping it. I like the idea though. Naming it cli.php might suffice for now. Headers already sent: Replaced the Reporting: Sounds good, either Argument parsing/default paths: Sounds reasonable. I modified the script look in the cwd by default. Enabling basic option value parsing was easy enough; mogelbrod/kirby-staticbuilder@1c4e856 Dry-run by default: I went all the way and converted the script into an actual CLI instead; mogelbrod/kirby-staticbuilder@8f7b622 Page collection: Good idea; mogelbrod/kirby-staticbuilder@91b0689 |
Closing feature requests as described in #40. |
Priority is having a 1.0 / 1.x that works well for generating a static site when visiting a particular route. But an alternative command-line tool could be nice.
php site/plugins/staticbuilder/cli.php [params]
?The text was updated successfully, but these errors were encountered: