How To Use
History Key
- New content
Removed content
Recent Versions
Choose two versions to compare, or click the link to view it.
ThereYou iscan use Code to Diagram in two waysways:
Locally
Diagram todisplayed usein the code to diagram into your projectLocally
Diagram to screenbrowser
Into the bootstrap file insert thisthese command:commands:
<?php
// code to diagram { //
require_once( '../../public/codetodiagram.php');
CodeToDiagram::getInstance()->start();
// } end code to diagram //
(...)
your code here
(...)
?>
Remember that:that thethe "../../public/codetodiagram.php" must be the valid relative path to acess your file.
With just this command you will see the diagram when you run your program.code.
<?php
//Diagram codesaved to diagram { //
require_once( '../../public/codetodiagram.php' );CodeToDiagram::getInstance()->start();
// } end code to diagram //
// regular page { //
require_once( 'Wolf.class.php' );require_once( 'Pig.class.php' );require_once( 'House.class.php' );require_once( 'History.class.php' );
new History();
// } end regular page //
?>
Diagram To Filefile
If you want to save the diagram result into a separated file, you can config the class CodeToDiagram like this:
<?php
(...)// code to diagram { //
require_once( '../../public/codetodiagram.php');
CodeToDiagram::getInstance()->setOutputType( 'file' ); // can be"file"or "screen"
CodeToDiagram::getInstance()->setFileName( 'myfile.html' ); // se the filename of diagram
(...)
?>
So, we can change the old example to save the diagram into a file:
<?php
// code to diagram { //
require_once( '../../public/codetodiagram.php' );
CodeToDiagram::getInstance()->setOutputType('file');
CodeToDiagram::getInstance()->setFileName( 'sequence.html' );
CodeToDiagram::getInstance()->start();
// } end code to diagram //
// regular page { //
require_once( 'Wolf.class.php' );require_once( 'Pig.class.php' );require_once( 'House.class.php' );require_once( 'History.class.php' );
new History();
// } end regular page // //
?>(...)
your code here
(...)
?>
You can also generate a diagram of just part of a code execution
Diagram of Stretchpart of Executionan execution
<?php
// code to diagram include { //
require_once( '../../public/codetodiagram.php' );
CodeToDiagram::getInstance()->start();
// } end of the code to diagram include //
// start of regular page { //
require_once( 'Wolf.class.php' );
require_once( 'Pig.class.php' );
require_once( 'House.class.php' );
require_once( 'History.class.php' );
// start the first diagram { //
CodeToDiagram::getInstance()->restart(); // clear the diagram history //
CodeToDiagram::getInstance()->setOutputType( 'file' );
CodeToDiagram::getInstance()->setFileName( 'diagram1.html' );
$objPig = new LitllePig();
$objPig->say( "Hello there!!" );
CodeToDiagram::getInstance()->save();
// } end of the first diagram //
// start of no diagram code { //
$objPig->say( "This will be a secret" );
// } end of no diagram code //
// start of second diagram { //
CodeToDiagram::getInstance()->restart(); // clear the diagram history //
CodeToDiagram::getInstance()->setOutputType( 'file' );
CodeToDiagram::getInstance()->setFileName( 'diagram2.html' );
$objPig = new LittlePig();
$objPig->say( "This will be saved" );
CodeToDiagram::getInstance()->save();
// } end of second diagram //
// } end of regular page //
?>
RemoteRemotely
Still in development.
Should work just like the local acess, without the no need to download the code:
<?php
// code to diagram { //
require_once( 'http://code.assembla.com/codetodiagram/subversion/node/blob/_start.php' );
CodeToDiagram::getInstance()->start();
// } end code to diagram //
// regular page { //
require_once( 'Wolf.class.php' );
require_once( 'Pig.class.php' );
require_once( 'House.class.php' );
require_once( 'History.class.php' );
new History();
// } end regular page //
?>
Results
The diagram generated will be a html with javascript what describe the execution. Some style changes are under development and some new informations as show the code line of the message should be add soon.
To see some example this example page will create this diagram.