Getting Started Loading components and error handling

Loading Components

No file of the SetaPDF 2 components is using include(), require() or a simliar statement to load a class/file. All PHP classes/files loading is done via a single autoload function which will be registered with spl_autoload_register when the file /library/SetaPDF/Autoload.php is required once:




After that all PHP classes and interfaces will be loaded automatically when they are needed. That's it!

With Composer

If you'd installed the component through Composer you can use the autoloader instance from Composer:

require 'vendor/autoload.php';

Error Handling

In SetaPDF 2 the error handling is done by throwing Exceptions throughout.

All SetaPDF exceptions are based on the SetaPDF_Exception class.

Furthermore the code will throw exceptions of following types: InvalidArgumentException, BadMethodCallException

So make sure that you catch at least the global Exception to keep control over the code flow:

try {
} catch (\SetaPDF_Exception $e) {
    // SetaPDF specific error
} catch (\Exception $e) {
    // global exception handling