Run PHP script?

  • Apologies in advance if this has been addressed elsewhere, but how do you get PHP to execute in PageKit? For example, putting the following in the Code section doesn't render Day/Time like in a normal PHP page, wondering where in PageKit it does.

    1. <?php
    2. // Server is Central Standard Time
    3. $today = date("D g:i A");
    4. echo $today;
    5. echo ' (CST)';
    6. ?>


  • As far is i know, i would say you need to create an extension for that.


    Depending on your requirements it could be even easier to do that by an extension. It's not difficult to create an extension and we can help you out with that :)

    If you'd like to use something like "inline-PHP": This is often not recommendable. I know that there are extensions for WordPress or Joomla!, which provide something like that - but in the past there have been security issues with this - because the PHP-code is often being executed using exec (my provider does not even allow that ;) ) and if there's a possibility to modify the original PHP, almost everything will be executed.

  • Thanks again for the replies. I started reading about extensions. So unlike typical PHP pages, you can't do calls to MySQL, run PHP code blocks or use SSI in the HTML itself, but have to use extensions for that?

  • Hi bobafifi

    Well - what do you mean with

    typical PHP pages


    I don't know what this should be...? Maybe you mean a output of pure PHP in your browser?

    If so: No. That's not possible for good reason - and it's not possible in most popular CMS without plugins or hacks I wrote about in my last reply.

    The question is: What do you want to archive? It is really easy to extend Pagekit - but to do that, you need to know what you want to do. Depending on your requirements you could:

    • Write your own extension (maybe even a big one with custom routes, an API, controllers, ...)
    • Write an extension (maybe it's enough to write a small one that consists of 3 files only (index.php, composer.json, scripts.php))
    • Write an extension that provides a content-plugin
    • Add the stuff you need to a theme

    So maybe it would be a good idea to tell us what you want to archive :) I'm sure there's a solution for that :) 

  • Thanks. I'd like to understand how to use dynamic elements like Server Side Includes (SSI) within PageKit

    1. <?php require '…/includes/example.php' ; ?>

    or run a MySQL calendar script (which I use on other non-CMS sites) or even how to execute a PHP generated "Hello World!" in the program. Thanks again for all your help with this!

  • Hi...

    Alright... Well - Pagekit makes massive use of namespaces. So try not to include files manually, when it comes to your first extension.

    A "hello world"-extension is really easy to do.

    Have a look at:



    If you simply want to write a "hello world" extension, you can do this with a 2-files-extension (index.php and composer.json).

    Should be something like that:

    It's not tested - but should be something like that ;)