Installation - serverboy/Interchange GitHub Wiki
Drop the whole package in the root directory of your site. The index.php
file should otherwise be accessible via http://foo.bar/index.php
. Make sure the .htaccess
file is properly installed in the root as well and that mod_rewrite
is enabled in Apache.
Though it is likely that
mod_rewrite
is already enabled, you may need to turn it on yourself. To enablemod_rewrite
on most *nix installations, simply run a command likeln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load && /etc/init.d/apache2 restart
. This will load in the rewrite extension and reboot Apache.
Create a file in /etc/nginx/sites-available/
containing something like this:
server {
listen 80;
server_name example.com sub.example.com shortlin.ks;
error_log /var/log/nginx/com.example.errors.log warn;
root /var/www/interchange.com.example;
index index.php index.html;
fastcgi_index index.php;
location / {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_pass unix:/var/run/php-fpm.sock;
}
}
This script assumes that you’ve using PHP-FPM with FastCGI and it’s set up with all of the default file paths.
You’ll then install Interchange to /var/www/interchange.com.example/
.
The next step is to ensure all of the appropriate directories are created. Make sure that /views
and /endpoints
both exist. If they do not, create these directories.
Your next step is to load in application endpoints. An application endpoint is similar to an app in Django. Unlike a Django app, however, your endpoint doesn’t need to be specifically designed for use with Interchange.
Endpoints should be loaded into the /endpoints
directory. The name of directory that the endpoint is contained within (i.e.: my_endpoint
, as below) will be used to refer to the application endpoint.
/endpoints /my_endpoint index.php header.php footer.php /another_endpoint endpoint.php add.php remove.php /static_endpoint default.css jquery.js
There are two types of application endpoints:
An Interchange endpoint is an endpoint that has been specifically built for compatibility with Interchange, containing code that takes full advantage of the power and functionality of the Interchange back-end. This type of endpoint is the default endpoint; if an endpoint is referenced, this type of endpoint will be searched for first.
An Interchange Endpoint is defined by placing a file called endpoint.php
in the root of of the endpoint directory (see /another_endpoint
above). If Interchange detects this file, it will automatically be assumed that the endpoint is an Interchange endpoint and the application will be loaded as such.
A traditional endpoint is effectively a standard PHP application: the root page is named index.php
and subpages exist adjacent to the root page or in subdirectories. A traditional endpoint is characterized by a lack of an endpoint.php
file. If no endpoint.php
exists, Interchange will attempt to emulate a standard file-based web server (such as Apache under the default configuration).
Interchange will first test if the URL corresponding to the request exists in the endpoint directory. If the URL does not correspond to an object, a 404 error is returned. If the URL corresponds to a file, the file is served. If the URL corresponds to a directory, a “default file” is searched for in the directory. A default file is a file like index.php
or index.html
. This list of default files can be found in /defaults.php
.
Note: URLs without a trailing slash WILL NOT (by default) automatically correspond or redirect to directories. This functionality can be adjusted in
constants.php
.
The PHP include_path
value will automatically be appended with the application endpoint’s root using ini_set
.
First and foremost, check out constants.php
and double check that everything there is kosher.
Next up, you need to modify your index.json
file. This file is the file that describes the rules that Interchange should follow when routing requests for your application. Information on this file can be found in index.json Reference.
You’ve successfully set up a new instance of Interchange. Now get to work!