mxGraph PHP

Installation

The following assumes that an Apache server or another server capable of running PHP 5 is running on the default port (80) on localhost. The mxGraph top-level directory is assumed to be located at http://localhost/mxgraph.

Examples

Graph

In this example, a graph is programmatically created and turned into a PNG image. Point your browser to http://localhost/mxgraph/php/examples/graph.php to run this example.

Reader

Creates a HTML graphical representation for a GraphView which is stored in an XML file. Point your browser to http://localhost/mxgraph/php/examples/reader.php to run this example.

Server

In order to be able to save files, the server.php file demonstrates how to accept a post request from a client, and put the data from the client request into a file on the disk.

Before accessing the HTML files, you must modify the config file of the example you want to use. For example, when using the diagrameditor.html file, you should modify javascript/examples/editors/config/diagrameditor.xml. The only change to the config file is to add the urlPost attribute to the mxEditor node as follows:

<mxEditor urlPost="php/examples/server.php" ... >

This enables the save function in the editor and will post the XML of the current diagram to the server.php on the server. The script will write the diagram to a local file called diagram.xml in the same directory as the script is located.

Note that you will have to add the save action in the user interface. To add the save action to the dropdown list of actions, change the items in the diagrameditor.html file as follows:

var items = ['redo', 'ungroup', 'cut', 'copy', 'paste', 'show', 'exportImage', 'save'];

To use the example, point your browser to http://localhost/mxgraph/javascript/examples/editors/diagrameditor.html

Session

The session.php example demonstrates the sharing of diagrams across a number of clients. The program itself does not have an object representation of the graph in memory, it only serves as a dispatcher for the XML data among the clients.

To use the example, the respective session URLs must be assigned in the mxEditor either programmatically or by use of the same config file as above. For diagram sharing, the following attributes must be assigned:

<mxEditor urlInit="/mxgraph/php/examples/session.php?init"
			 urlPoll="/mxgraph/php/examples/session.php"
			 urlNotify="/mxgraph/php/examples/session.php">

To use the example, point your browser to http://localhost/mxgraph/javascript/examples/editors/diagrameditor.html


© 2006-2013 by JGraph Ltd.