ZF4 Blog

Creating an XSD Server Using Slim

Following the work I did yesterday to create Zend ACL definitions from XML files, it followed that I needed to host the XSD in a public place. The Slim Framework is ideal for these jobs, so here it is:

use Slim\Slim;

$app = new Slim();
$app->xsdDir = realpath(__DIR__ . '/..') . '/xsd';

 * Define routes
        function($name) use ($app) {
            if (!file_exists($file)) {
                $app->halt("{$name} does not exist");
            $app->response->headers->set("Content-type", "application/octet-stream");


Now this is very raw, and now doubt can benefit from some tarting up, getting a nice homepage display etc, but in essence it works. Basically, store your XSD files under the public root in the xsd directory and then call the site with /schema/name e.g.