Serving a default representation for a directory when using the file adapter
When we use the file adapter to store our resource data, we often want to have a resource with the same name as a directory. Of course, file systems don't allow us to have both a file and a directory with the same name, so this leaves us with a problem.
The file adapter solves this problem in the same way as most Web servers, we introduce the idea of a default document. This allows us to create a resource with a specific name within the directory that will be used if the URL mapping to the directory itself is requested.
For example, if we have a file system that looks like the following, then the
on requesting /example, Tonic will actually process the resource
/example/default.html:
/helloworld.html /example/default.html /example/document.html
We can use whatever we like a the filename for our default document by passing in the name we want to use to our file adapter when we create it:
// create default adapter $adapter =& new FileAdapter($mimetypes, 'resources', 'index.html');Back to documentation home