If you want to deploy your application with the bare minimum required Zend Framework scripts, attach the following PHP error handling function and run your application through all it’s features until it no longer complains about missing required scripts :)

Goal: minimize the deployment package!

Had to copy these additional directories (it tried to load through it via plug-in logic instead of throwing a require_once error) :
- Zend\Application\Resource
- Zend\Filter
- Zend\Controller\Action\Helper

That’s what it needed for a plain index controller and a rest index controller with json support (module), 171 Files and 33 Folders of the Zend Library.
Could probably scale it down more if we cherry pick from the directories mentioned above.

function error_handler($errno, $errstr, $errfile, $errline) {
	// ------------------------------ START CONFIGURATION --------------------------------------
	$sourcedir = 'X:\source\library';
	$destination = realpath(APPLICATION_PATH . '\library');
	// ------------------------------ END CONFIGURATION ----------------------------------------

	// echo $errstr;
	// echo "/Zend[a-zA-Z0-9.\\\\\/]*/i"."<br/>";

	preg_match("/Zend[a-zA-Z0-9.\\\\\/]*/i", $errstr, $matches);
	echo "<br/>missing script matches<br/>";
	var_dump($matches);	

	if (isset($matches[0])) {
		echo "copy file<br/>";

		/* Examples:
		 Zend/Loader/PluginLoader/Interface.php
		 Zend\Application\Bootstrap\Exception.php
		 */

		// echo '/Zend[a-zA-Z0-9\\\\\/]*[\\\\\/]{1}/i'."<br/>";
		preg_match('/Zend[a-zA-Z0-9\\\\\/]*[\\\\\/]{1}/i', $matches[0], $matchpath);

		echo "path matches<br/>";
		var_dump($matchpath);

		echo 'path: '.$matchpath[0]."<br/>";
		if (isset($matchpath[0])) {
			echo "creating: ".$destination.'\\'.$matchpath[0]."<br/>";
			// create a missing path
			mkdir ($destination.'\\'.$matchpath[0] ,0777, true);
		}

		// copy the file
		copy ( $sourcedir.'\\'.$matches[0] , $destination.'\\'.$matches[0] );
	}
}

set_error_handler ( 'error_handler', E_ALL );