File: examples/runtest.php

Recommend this page to a friend!
  Classes of Jorge Castro  >  PHP AutoLoad One  >  examples/runtest.php  >  Download  
File: examples/runtest.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP AutoLoad One
Generate scripts to autoload classes of a project
Author: By
Last change:
Date: 3 months ago
Size: 1,965 bytes
 

Contents

Class file image Download
<?php
namespace dummy;

use
ClassWithoutNameSpace;


use
mapache_commons\Collection;

define("_AUTOLOAD_ONEDEBUG",true);

// both includes works:
// include "autoload.php";
// or
// include "folder/subfolder/autoload.php";

include "autoload.php";

echo
"<h1>Testing..</h1>";

// basic
$c2=new \nsfolder\NaturalClass();
echo
'$c2=new \folder\NaturalClass();<br>';
// same folders
$c1=new \nsfolder\subnamespace\AnotherNaturalClass();
echo
'$c1=new \nsfolder\subnamespace\AnotherNaturalClass();<br>';
$c3=new \nsfolder\subnamespace\AnotherNaturalClass2();
echo
'$c3=new \nsfolder\subnamespace\AnotherNaturalClass2();<br>';
$c4=new \nsfolder\subnamespace\MoreNaturalClass();
echo
'$c4=new \nsfolder\subnamespace\MoreNaturalClass();<br>';
// same folder, again
$c4=new \nsfolder\subnamespace\MoreNaturalClass();
echo
'$c4=new \nsfolder\subnamespace\MoreNaturalClass();<br>';
// same namespace, different folder
$c5=new \nsfolder\subnamespace\CustomClass();
echo
'$c5=new \nsfolder\subnamespace\CustomClass();<br>';
// one file, two namespaces
$c6=new \MyProject\Connection();
echo
'$c6=new \MyProject\Connection();<br>';
$c8=new \AnotherProject\Connection();
echo
'$c8=new \AnotherProject\Connection();<br>';
// class without namespace
$c9=new ClassWithoutNameSpace();
echo
'$c9=new ClassWithoutNameSpace();<br>';
// class compressed
$c10=new \folder_ns\subnamespace\ClassFolder1\ClassFolder1();
echo
'$c10=new \folder_ns\subnamespace\ClassFolder1\ClassFolder1();<br>';
$c11=new \ClassFolder1();
echo
'$c11=new \ClassFolder1();<br>';
// class external. It is loaded externally. Of course it will fail if you are not loading (the class is not supplied in this project)
/*
$ex=new \nsexternal\External();
echo '$ex=new \nsexternal\External();<br>';
$ex2=Collection::first(array());
*/
echo "Ok<br>";

echo
"<span style='color:red'>The next command should raise an error (we test if the file doesn't exist):<br></span>";
$cE1 = new \nsfolder\subnamespace\CustomClassE();


For more information send a message to info at phpclasses dot org.