midgard-apache, first requests

Posted on 2007-05-09 12:38:44 EEST.

image

First requests using new midgard-apache module :)

What's changed?

  • Apache module initialize core's MidgardRequest object so it's available in midgard-php extension without need to write hacks.

It means that one should be able to write the same PHP application for command line and for web environment.

  • $_MIDGARD global array has new key pages initialized as array with midgard_page objects.

All pages found from url are stored in this array, so there's no need to get page object during the request as it's already available. This array is always initialized for website. At least it always has host's root page available.

$_MIDGARD['pages'][0]

Always contain root page.

  • midgard-root.php file is parsed after connection for request is established. Not before.

$_MIDGARD superglobal is available in any self defined root file. In the first line of it. You do not have to initialize your application from code-global page element. You can initialize it in file, before midgard style engine starts.

My simple test root file looks like this:

<img src="/spider-admin/spider_logo.png">
<?php
    foreach($_MIDGARD['pages'] as $page) {
        echo $page->name;
        echo " &raquo; ";
}
?>

To get my screenshot I requested page with such url:

myhost:8101/spider-admin/topic/article/1

And of course $_MIDGARD['argc'] is 1 and $_MIDGARD['argv][0] is "1". spider-admin, topic and article are stored in $_MIDGARD['pages'] as 0, 1 and 2 index.

BTW, with very first request I did:

print_r($_MIDGARD);

And firefox wanted to install missed java runtime to run included plugin. What? I realized that print_r also printed 'article' midgard_page's content which contain java editor...

That's fun , I found java editor in application which I use for years at the moment when I completely rewrite midgard-apache and midgard-php ;)

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS