Kirby 3 way of exec-uting shell scripts, such as node scripts?

Is there any Kirby 3 specific way of running shell scripts such as node scripts?


Do you want to run those scripts from Kirby (e.g. from the Panel), or manually while the site is in development?

if you need a way to create one or more buttons in the panel linked to skripts easily consider my janitor plugin.

1 Like

@lukasbestle I want to run a script that creates a .ttf when a page is created on the panel, or when it is published or when the user presses a button. All of it on the live website, not during development.

Thanks , @bnomei, I will take a look at it!

So there is no Kirby 3 specific way of doing this?

Thank you

Sure, there’s hooks to hook into events as you mentioned:

  • page created
  • page published

If you need a custom action with UI (e.g. “button”), you could use @bnomei’s janitor plugin, or cook up your own.

I’ve built a “queue plugin” which has a basic API for working with events in an async way, if you’ld need it (e.g. if the creation of that ttf file would take too long).

1 Like

There is nothing special about running scripts from Kirby. As Kirby is built with PHP, you can use the standard PHP exec() function. As @bnomei and @bvdputte wrote, you can use hooks or Panel plugins as triggers.

1 Like

Thanks @lukasbestle, I was thinking perhaps some helpers.
Thanks again

If anyone can help me with this short question I would be infinitely grateful as I have no experience using node scripts on my server and am not even sure if the follow is possible – I have implemented the hook:

'page.update:after' => function($newpage, $oldPage) {},

I would like the hook to execute a short node.js script that is located in my site’s root folder using PHP’s exec()

Is it possilbe for such a node.js script to be executed in this way from Kirby?

AFAIK everything you can run in the command line can be envoked via PHP’s exec(). So, if node.js and dependencies etc are installed on the server you should be able to call this.