The following code will be used in the gateway PHP file (ress_gateway/index.php
), which can be placed anywhere provided we can put the .htaccess
file to redirect requests and at the same time define a proper base path in the JavaScript of the application:
include "../app/bootstrap.php"; require_once(APPLICATION_DIR."rest_slim/app.php"); $app = Rest_Slim::getInstance(); $app->setRoutes(); $app->run();
To easily connect all the dots, we define the following methods:
public function getGatewayUrl() { return $this->getRootUrl().$this->config['GATEWAY'].'/photos'; }
The output of the preceding function is consumed inside the JavaScript code as follows:
var rootURL = "<?php echo $this->getGatewayUrl(); ?>";
But we certainly can't call PHP from a .js
file. We use the templates placed in the app\rest_slim\assets\
directory—ajax.php
in this case. Then this file is loaded using the following code:
public function getJsApp() { $ajaxAppPath = $this->config...