Porting Existing Apps - serverboy/Interchange GitHub Wiki

The benefit of Interchange is that existing applications can be ported to work as application endpoints with little or no effort. Because of this, it’s dead simple to merge the functionality of all of your web applications into a single package.

The largest change that must be made to existing applications is likely to be file access. Since the origin script is not in the same directory as the application being run, scripts within application endpoints must take into account how files are required. For instance, the following code would not behave as expected within Interchange:

<?php
require("include.php");

The code above would load /include.php rather than the expected /endpoints/my_endpoint/include.php. To require the expected file instead, the following code would work properly:

<?php
require(PATH_PREFIX . "/include.php");

PATH_PREFIX does not contain a trailing slash.

The same procedure should be used with any function or code that accesses files.

⚠️ **GitHub.com Fallback** ⚠️