-
☆ A M B ☆
- 2,475 Posts
So what are people doing for Snippet development? I like to code in a text editor and be able to test my PHP code using "php -l myscript.php" -- but you can’t really do that if you’re using the modx object. Is there a file that can be included to gain access to the modx object and its methods? It would be great to be able to see the Snippet output directly on the command line... of course, once it was uploaded into the MODx database, I’d remove that include statement, but for development it would be great. When running a Snippet by previewing a page where the Snippet it called, I can’t see if or where the script errors out... I’d love to see some error messages and a line number, for example.
Does anyone have tips and tricks here? Where’s the MODx error log on my server?
I did some snippets to retrieve data from a custom database.
My snippets are acting as the controller in a MVC pattern, something like this:
[tt]<?php
$html = ’’;
require_once( ’./assets/site/.../lib.dbio.php’);
require_once( ’./assets/site/.../lib.dcio.php’);
$resArray = getStationDetails();
$html = showStationDetails( $resArray);
return $html;
?>[/tt]
lib.dbio.php contains all the ’model’ functions’, and lib.dcio.php copes with the ’view’ functions.
Development goes like this, put the snippet code in modx and elaborate the model and view functions outside of modx.
I’m using a WAMP-server locally for development and there’s a php error log I can read when my modx page goes blank...
Hope this helps?
A thing of beauty is a joy forever ( John Keats)
-
☆ A M B ☆
- 2,475 Posts
Thanks Avander_be. Maybe I misunderstood your post, but I think you missed what I’m after...
I need a way to have access to all the MODx methods... any time a $modx->some_function appears in my Snippets, I can no longer test that Snippet in my favorite text editor. I have to run it by pasting it into the manager and test the Snippet by loading a page that contains a call to that Snippet.
My guess is that its a few files in /manager/includes/ but I don’t know which ones and it’ll take me a long time to stumble through them.
It’s been a while since I’ve done it in 0.9.6, but I think if you include the index.php file in the site root, it will create a new $modx object for you.
-
☆ A M B ☆
- 2,475 Posts
Thanks, Bob. I’ll try that. All of a sudden I’m getting errors with unloaded php modules (???), so I’m not sure if I just killed my poor dev server or what.