
Once you have successfully connected to the API using the DIrectorPHP class, there is a world of data and imagery at your fingertips. To get acquainted with how the DirectorPHP class works, let's walk through a simple example which will show the most recently uploaded content from Director.
If you followed the getting started example, you should already have this in your index.php file:
<?php
include('classes/DirectorPHP.php');
$director = new Director('your-api-key', 'your-api-path');
echo('Connected!');
?>
Now it's time to fetch some content from Director. We use the content subclass to do that:
<?php
include('classes/DirectorPHP.php');
$director = new Director('your-api-key', 'your-api-path');
$recent = $director->content->all(array('limit' => 10));
?>
Our new line of code requests the 10 most recent pieces of content from our Director installation. We can now output the full size originals to the page:
<?php
include('classes/DirectorPHP.php');
$director = new Director('your-api-key', 'your-api-path');
$recent = $director->content->all(array('limit' => 10));
foreach($recent as $content) {
echo '<img src="' . $content->original->url . '" />';
}
?>
If you have uploaded videos recently, you will notice that they show up in the list as well. The all() method allows you to specify that you only want images:
<?php
include('classes/DirectorPHP.php');
$director = new Director('your-api-key', 'your-api-path');
$recent = $director->content->all(array('limit' => 10, 'only_images' => true));
foreach($recent as $content) {
echo '<img src="' . $content->original->url . '" />';
}
?>
So now you have a list of recent images, but who wants to display several megabyte original images in a list like this? In our next example, we'll use the DirectorPHP class to tap into Director's powerful on-demand image processing library.

