Re: Using Optional Dependencies... ???
| From: | Alan Knowles | Date: | Mon, 12 Apr 2004 01:32:37 +0000 |
| Subject: | Re: Using Optional Dependencies... ??? | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-27432@lists.php.net to get a copy of this message | ||
Having been caught by this quite a few times - code not working as expected because of optional dependancies..
I now kind of like the idea of
if ($options['use_some_package']) {
require_once 'The/Package.php';
......
}
Making it fail bad and hard due to a missing dependancy that you explicity ask to be included.... Seems a suitable result..
otherwise - using include_once without the @ and letting the end user call your method with the @, forcing them to silence it....
Regards
Alan
Jon Parise wrote:
On Sun, Apr 11, 2004 at 07:56:33PM -0400, Davey wrote:I have a query about how exactly to code optional dependencies... I use this:You can also do it this way: if ((@include_once 'XML/Beautifier.php') !== false) {@include_once 'XML/Beautifier.php';if (in_array('xml_beautifier',get_declared_classes())) { $beautifier = new XML_Beautifier; $code = trim($beautifier->formatString($code)); }I can think of no other way to do it......}