Well, your external PHP file would be your "connector" in this case, and some code like this should work (untested):
<?php
$basePath = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) );
/* Allow anonymous users */
define( 'MODX_REQP', false );
/* Require MODx configuration, and base connector file */
require_once( $basePath . '/config.core.php' );
require_once( MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php' );
require_once( MODX_CONNECTORS_PATH . 'index.php' );
/* Add your own initialization code for your component here */
/* Handle request */
$processorsPath = $modx->getOption( 'core_path' ) . 'components/MY_COMPONENT/processors/';
$modx->request->handleRequest( array(
'processors_path' => $processorsPath,
'location' => 'web'
) );
?>
A couple of notes:
1. The ’MODX_REQP’ define at the top allows non-validated users to access the connector. Remove this if only logged-in users should have access to this connector.
2. $basePath is the path to the MODx base. This example assumes your connector is located at /assets/components/MY_COMPONENT/connectors/my-connector.php
3. handleRequest()’s ’location’ parameter lets you [optionally] define a sub-directory of whatever the processors_path is. I generally store all manager processors inside processors/mgr and my web connectors inside processors/web - adjust accordingly. Now, passing an ’action’ request parameter to the connector will load up the appropriate processor. For example, passing "getlist" will load up the getlist processor inside your component’s processors/web/ directory.