Location: PHPKode > scripts > packagex > packagex/packagex_tips.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>packagex tips</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p>The best way to to use packagex for the management of your projects is to try to stick to very simple rules:</p>
<ul>
<li>You must give your file extension .class.php (e.g. ClassA.class.php)<br />
In case you have a different naming convention you can simply extend the Package class and override the import() and loadClasses() methods to match your requirements
</li>
<li>
<p>You should make sure that, if classes of a package need classes not part of the same package, the package of the classes to be found must have been imported before the call to import() method for the other package is made.<br />
This works the same for anyother type of inclusions in PHP, so it should not be causing problems.</p>
<p>For example</p>
<p>We have a class which provides definitions for methods to get values from a database.<br />
In order to do so we use a class such as MySQLquery.class.php which supports connecting to database and get values from it. Naturally we will have to make a call to import() method for the package containg MySQLquery before any other class using it.</p>
</li>
<li>You should try to organize your project so that abstract classes and interfaces are at top locations (directories) as opposed to concrete and implementing classes being stored in subfolders/subdirectories</li>
<li><strong>Finally the most needed tip of all!!!</strong>
<p>Sometimes you will have to provide one or more include_once() before definition of a classes.<br />
<p>This happens pretty rarely and it happens mainly when a class header declares to extend or implement an interface and these are in the same directory (part also of the same package).<br />
Because the import method does the job by reading a directory and by importing the files with extension .class.php sometimes a class is imported before an other. So you sometimes get an error saying a class could not find another.</p>
<p>I have made projects using this class for managing more than 150 files and it may have happened 6 to 10 times.</p>
<p>It is not much of an issue as you can simply go to the file screaming for the other class and do an include_once() bedore defining the class itself.</p>
</p>
</li>
</ul>
<p>I hope you gonna find it useful as I do</p>
</body>
</html>


Return current item: packagex