protected function createDeployment($deploymentName, $path = null)
    {
        $deploymentConfigurationPath = $this->getDeploymentsBasePath($path);
        $workspacesBasePath = $this->getWorkspacesBasePath();

        if (empty($deploymentName)) {
            $deploymentNames = $this->getDeploymentNames($path);
            if (count($deploymentNames) !== 1) {
                throw new InvalidConfigurationException('No deployment name given!', 1451865016);
            }
            $deploymentName = array_pop($deploymentNames);
        }

        $deploymentPathAndFilename = Files::concatenatePaths([$deploymentConfigurationPath, $deploymentName . '.php']);
        if (file_exists($deploymentPathAndFilename)) {
            $deployment = new Deployment($deploymentName);
            $deployment->setDeploymentBasePath($deploymentConfigurationPath);
            $deployment->setWorkspacesBasePath($workspacesBasePath);
            $tempPath = Files::concatenatePaths([$workspacesBasePath, $deploymentName]);
            $this->ensureDirectoryExists($tempPath);
            $deployment->setTemporaryPath($tempPath);
            require($deploymentPathAndFilename);
        } else {
            $this->createLogger()->error(sprintf("The deployment file %s does not exist.\n", $deploymentPathAndFilename));
            $deployment = new FailedDeployment();
        }

        return $deployment;
    }