diff --git a/bin/classmap_generator.php b/bin/classmap_generator.php deleted file mode 100644 index 1369f719..00000000 --- a/bin/classmap_generator.php +++ /dev/null @@ -1,155 +0,0 @@ - ] Library to parse; if none provided, assumes - * current directory - * --output|-o [ ] Where to write autoload file; if not provided, - * assumes "autoload_classmap.php" in library directory - * --overwrite|-w Whether or not to overwrite existing autoload - * file - */ - -$libPath = dirname(__FILE__) . '/../library'; -if (!is_dir($libPath)) { - // Try to load StandardAutoloader from include_path - if (false === include('Zend/Loader/StandardAutoloader.php')) { - echo "Unable to locate autoloader via include_path; aborting" . PHP_EOL; - exit(2); - } -} else { - // Try to load StandardAutoloader from library - if (false === include(dirname(__FILE__) . '/../library/Zend/Loader/StandardAutoloader.php')) { - echo "Unable to locate autoloader via library; aborting" . PHP_EOL; - exit(2); - } -} - -// Setup autoloading -$loader = new Zend_Loader_StandardAutoloader(); -$loader->setFallbackAutoloader(true); -$loader->register(); - -$rules = array( - 'help|h' => 'Get usage message', - 'library|l-s' => 'Library to parse; if none provided, assumes current directory', - 'output|o-s' => 'Where to write autoload file; if not provided, assumes "autoload_classmap.php" in library directory', - 'overwrite|w' => 'Whether or not to overwrite existing autoload file', -); - -try { - $opts = new Zend_Console_Getopt($rules); - $opts->parse(); -} catch (Zend_Console_Getopt_Exception $e) { - echo $e->getUsageMessage(); - exit(2); -} - -if ($opts->getOption('h')) { - echo $opts->getUsageMessage(); - exit(); -} - -$path = $libPath; -if (array_key_exists('PWD', $_SERVER)) { - $path = $_SERVER['PWD']; -} -if (isset($opts->l)) { - $path = $opts->l; - if (!is_dir($path)) { - echo "Invalid library directory provided" . PHP_EOL . PHP_EOL; - echo $opts->getUsageMessage(); - exit(2); - } - $path = realpath($path); -} - -$usingStdout = false; -$output = $path . DIRECTORY_SEPARATOR . 'autoload_classmap.php'; -if (isset($opts->o)) { - $output = $opts->o; - if ('-' == $output) { - $output = STDOUT; - $usingStdout = true; - } elseif (!is_writeable(dirname($output))) { - echo "Cannot write to '$output'; aborting." . PHP_EOL - . PHP_EOL - . $opts->getUsageMessage(); - exit(2); - } elseif (file_exists($output)) { - if (!$opts->getOption('w')) { - echo "Autoload file already exists at '$output'," . PHP_EOL - . "but 'overwrite' flag was not specified; aborting." . PHP_EOL - . PHP_EOL - . $opts->getUsageMessage(); - exit(2); - } - } -} - -$strip = $path; - -if (!$usingStdout) { - echo "Creating class file map for library in '$path'..." . PHP_EOL; -} - -// Get the ClassFileLocator, and pass it the library path -$l = new Zend_File_ClassFileLocator($path); - -// Iterate over each element in the path, and create a map of -// classname => filename, where the filename is relative to the library path -$map = new stdClass; -$strip .= DIRECTORY_SEPARATOR; -function createMap(Iterator $i, $map, $strip) { - $file = $i->current(); - $namespace = empty($file->namespace) ? '' : $file->namespace . '\\'; - $filename = str_replace($strip, '', $file->getRealpath()); - - // Windows portability - $filename = str_replace(array('/', '\\'), "' . DIRECTORY_SEPARATOR . '", $filename); - - $map->{$namespace . $file->classname} = $filename; - - return true; -} -iterator_apply($l, 'createMap', array($l, $map, $strip)); - -// Create a file with the class/file map. -// Stupid syntax highlighters make separating < from PHP declaration necessary -$dirStore = 'dirname_' . uniqid(); -$content = '<' . "?php\n" - . '$' . $dirStore . " = dirname(__FILE__);\n" - . 'return ' . var_export((array) $map, true) . ';'; - -// Prefix with dirname(__FILE__); modify the generated content -$content = preg_replace('#(=> )#', '$1$' . $dirStore . ' . DIRECTORY_SEPARATOR . ', $content); -$content = str_replace("\\'", "'", $content); - -// Write the contents to disk -file_put_contents($output, $content); - -if (!$usingStdout) { - echo "Wrote classmap file to '" . realpath($output) . "'" . PHP_EOL; -} diff --git a/bin/zf.bat b/bin/zf.bat deleted file mode 100644 index 6a9fcb64..00000000 --- a/bin/zf.bat +++ /dev/null @@ -1,44 +0,0 @@ -@ECHO off -REM Zend Framework -REM -REM LICENSE -REM -REM This source file is subject to the new BSD license that is bundled -REM with this package in the file LICENSE.txt. -REM It is also available through the world-wide-web at this URL: -REM http://framework.zend.com/license/new-bsd -REM If you did not receive a copy of the license and are unable to -REM obtain it through the world-wide-web, please send an email -REM to license@zend.com so we can send you a copy immediately. -REM -REM Zend -REM Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) -REM http://framework.zend.com/license/new-bsd New BSD License - - -REM Test to see if this was installed via pear -SET ZTMPZTMPZTMPZ=@ph -SET TMPZTMPZTMP=%ZTMPZTMPZTMPZ%p_bin@ -REM below @php_bin@ -FOR %%x IN ("@php_bin@") DO (if %%x=="%TMPZTMPZTMP%" GOTO :NON_PEAR_INSTALLED) - -GOTO PEAR_INSTALLED - -:NON_PEAR_INSTALLED -REM Assume php.exe is executable, and that zf.php will reside in the -REM same file as this one -SET PHP_BIN=php.exe -SET PHP_DIR=%~dp0 -GOTO RUN - -:PEAR_INSTALLED -REM Assume this was installed via PEAR and use replacements php_bin & php_dir -SET PHP_BIN=@php_bin@ -SET PHP_DIR=@php_dir@ -GOTO RUN - -:RUN -SET ZF_SCRIPT=%PHP_DIR%\zf.php -"%PHP_BIN%" -d safe_mode=Off -f "%ZF_SCRIPT%" -- %* - - diff --git a/bin/zf.php b/bin/zf.php deleted file mode 100644 index c9699fce..00000000 --- a/bin/zf.php +++ /dev/null @@ -1,624 +0,0 @@ -bootstrap(); - $zf->run(); - } - - /** - * bootstrap() - * - * @return ZF - */ - public function bootstrap() - { - // detect settings - $this->_mode = $this->_detectMode(); - $this->_homeDirectory = $this->_detectHomeDirectory(); - $this->_storageDirectory = $this->_detectStorageDirectory(); - $this->_configFile = $this->_detectConfigFile(); - - // setup - $this->_setupPHPRuntime(); - $this->_setupToolRuntime(); - } - - /** - * run() - * - * @return ZF - */ - public function run() - { - switch ($this->_mode) { - case 'runError': - $this->_runError(); - $this->_runInfo(); - break; - case 'runSetup': - if ($this->_runSetup() === false) { - $this->_runInfo(); - } - break; - case 'runInfo': - $this->_runInfo(); - break; - case 'runTool': - default: - $this->_runTool(); - break; - } - - return $this; - } - - /** - * _detectMode() - * - * @return ZF - */ - protected function _detectMode() - { - $arguments = $_SERVER['argv']; - - $mode = 'runTool'; - - if (!isset($arguments[0])) { - return $mode; - } - - if ($arguments[0] == $_SERVER['PHP_SELF']) { - $this->_executable = array_shift($arguments); - } - - if (!isset($arguments[0])) { - return $mode; - } - - if ($arguments[0] == '--setup') { - $mode = 'runSetup'; - } elseif ($arguments[0] == '--info') { - $mode = 'runInfo'; - } - - return $mode; - } - - - /** - * _detectHomeDirectory() - detect the home directory in a variety of different places - * - * @param bool $mustExist Should the returned value already exist in the file system - * @param bool $returnMessages Should it log messages for output later - * @return string - */ - protected function _detectHomeDirectory($mustExist = true, $returnMessages = true) - { - $homeDirectory = null; - - $homeDirectory = getenv('ZF_HOME'); // check env var ZF_HOME - if ($homeDirectory) { - $this->_logMessage('Home directory found in environment variable ZF_HOME with value ' . $homeDirectory, $returnMessages); - if (!$mustExist || ($mustExist && file_exists($homeDirectory))) { - return $homeDirectory; - } else { - $this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages); - } - } - - $homeDirectory = getenv('HOME'); // HOME environment variable - - if ($homeDirectory) { - $this->_logMessage('Home directory found in environment variable HOME with value ' . $homeDirectory, $returnMessages); - if (!$mustExist || ($mustExist && file_exists($homeDirectory))) { - return $homeDirectory; - } else { - $this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages); - } - - } - - $homeDirectory = getenv('HOMEPATH'); - - if ($homeDirectory) { - $this->_logMessage('Home directory found in environment variable HOMEPATH with value ' . $homeDirectory, $returnMessages); - if (!$mustExist || ($mustExist && file_exists($homeDirectory))) { - return $homeDirectory; - } else { - $this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages); - } - } - - $homeDirectory = getenv('USERPROFILE'); - - if ($homeDirectory) { - $this->_logMessage('Home directory found in environment variable USERPROFILE with value ' . $homeDirectory, $returnMessages); - if (!$mustExist || ($mustExist && file_exists($homeDirectory))) { - return $homeDirectory; - } else { - $this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages); - } - } - - return false; - } - - /** - * _detectStorageDirectory() - Detect where the storage directory is from a variaty of possiblities - * - * @param bool $mustExist Should the returned value already exist in the file system - * @param bool $returnMessages Should it log messages for output later - * @return string - */ - protected function _detectStorageDirectory($mustExist = true, $returnMessages = true) - { - $storageDirectory = false; - - $storageDirectory = getenv('ZF_STORAGE_DIR'); - if ($storageDirectory) { - $this->_logMessage('Storage directory path found in environment variable ZF_STORAGE_DIR with value ' . $storageDirectory, $returnMessages); - if (!$mustExist || ($mustExist && file_exists($storageDirectory))) { - return $storageDirectory; - } else { - $this->_logMessage('Storage directory does not exist at ' . $storageDirectory, $returnMessages); - } - } - - $homeDirectory = ($this->_homeDirectory) ? $this->_homeDirectory : $this->_detectHomeDirectory(true, false); - - if ($homeDirectory) { - $storageDirectory = $homeDirectory . '/.zf/'; - $this->_logMessage('Storage directory assumed in home directory at location ' . $storageDirectory, $returnMessages); - if (!$mustExist || ($mustExist && file_exists($storageDirectory))) { - return $storageDirectory; - } else { - $this->_logMessage('Storage directory does not exist at ' . $storageDirectory, $returnMessages); - } - } - - return false; - } - - /** - * _detectConfigFile() - Detect config file location from a variety of possibilities - * - * @param bool $mustExist Should the returned value already exist in the file system - * @param bool $returnMessages Should it log messages for output later - * @return string - */ - protected function _detectConfigFile($mustExist = true, $returnMessages = true) - { - $configFile = null; - - $configFile = getenv('ZF_CONFIG_FILE'); - if ($configFile) { - $this->_logMessage('Config file found environment variable ZF_CONFIG_FILE at ' . $configFile, $returnMessages); - if (!$mustExist || ($mustExist && file_exists($configFile))) { - return $configFile; - } else { - $this->_logMessage('Config file does not exist at ' . $configFile, $returnMessages); - } - } - - $homeDirectory = ($this->_homeDirectory) ? $this->_homeDirectory : $this->_detectHomeDirectory(true, false); - if ($homeDirectory) { - $configFile = $homeDirectory . '/.zf.ini'; - $this->_logMessage('Config file assumed in home directory at location ' . $configFile, $returnMessages); - if (!$mustExist || ($mustExist && file_exists($configFile))) { - return $configFile; - } else { - $this->_logMessage('Config file does not exist at ' . $configFile, $returnMessages); - } - } - - $storageDirectory = ($this->_storageDirectory) ? $this->_storageDirectory : $this->_detectStorageDirectory(true, false); - if ($storageDirectory) { - $configFile = $storageDirectory . '/zf.ini'; - $this->_logMessage('Config file assumed in storage directory at location ' . $configFile, $returnMessages); - if (!$mustExist || ($mustExist && file_exists($configFile))) { - return $configFile; - } else { - $this->_logMessage('Config file does not exist at ' . $configFile, $returnMessages); - } - } - - return false; - } - - - /** - * _setupPHPRuntime() - parse the config file if it exists for php ini values to set - * - * @return void - */ - protected function _setupPHPRuntime() - { - // set php runtime settings - ini_set('display_errors', true); - - // support the changing of the current working directory, necessary for some providers - $cwd = getenv('ZEND_TOOL_CURRENT_WORKING_DIRECTORY'); - if ($cwd != '' && realpath($cwd)) { - chdir($cwd); - } - - if (!$this->_configFile) { - return; - } - $zfINISettings = parse_ini_file($this->_configFile); - $phpINISettings = ini_get_all(); - foreach ($zfINISettings as $zfINIKey => $zfINIValue) { - if (substr($zfINIKey, 0, 4) === 'php.') { - $phpINIKey = substr($zfINIKey, 4); - if (array_key_exists($phpINIKey, $phpINISettings)) { - ini_set($phpINIKey, $zfINIValue); - } - } - } - } - - /** - * _setupToolRuntime() - setup the tools include_path and load the proper framwork parts that - * enable Zend_Tool to work. - * - * @return void - */ - protected function _setupToolRuntime() - { - - $includePathPrepend = getenv('ZEND_TOOL_INCLUDE_PATH_PREPEND'); - $includePathFull = getenv('ZEND_TOOL_INCLUDE_PATH'); - - // check if the user has not provided anything - if (!($includePathPrepend || $includePathFull)) { - if ($this->_tryClientLoad()) { - return; - } - } - - // if ZF is not in the include_path, but relative to this file, put it in the include_path - if ($includePathPrepend || $includePathFull) { - if (isset($includePathPrepend) && ($includePathPrepend !== false)) { - set_include_path($includePathPrepend . PATH_SEPARATOR . get_include_path()); - } elseif (isset($includePathFull) && ($includePathFull !== false)) { - set_include_path($includePathFull); - } - } - - if ($this->_tryClientLoad()) { - return; - } - - $zfIncludePath['relativePath'] = dirname(__FILE__) . '/../library/'; - if (file_exists($zfIncludePath['relativePath'] . 'Zend/Tool/Framework/Client/Console.php')) { - set_include_path(realpath($zfIncludePath['relativePath']) . PATH_SEPARATOR . get_include_path()); - } - - if (!$this->_tryClientLoad()) { - $this->_mode = 'runError'; - return; - } - } - - /** - * _tryClientLoad() - Attempt to load the Zend_Tool_Framework_Client_Console to enable the tool to run. - * - * This method will return false if its not loaded to allow the consumer to alter the environment in such - * a way that it can be called again to try loading the proper file/class. - * - * @return bool if the client is actuall loaded or not - */ - protected function _tryClientLoad() - { - $this->_clientLoaded = false; - $fh = @fopen('Zend/Tool/Framework/Client/Console.php', 'r', true); - if (!$fh) { - return $this->_clientLoaded; // false - } else { - fclose($fh); - unset($fh); - include 'Zend/Tool/Framework/Client/Console.php'; - $this->_clientLoaded = class_exists('Zend_Tool_Framework_Client_Console'); - } - - return $this->_clientLoaded; - } - - /** - * _runError() - Output the error screen that tells the user that the tool was not setup - * in a sane way - * - * @return void - */ - protected function _runError() - { - - echo <<_messages) . PHP_EOL; - - echo PHP_EOL; - - echo 'To change the setup of this tool, run: "zf --setup"'; - - echo PHP_EOL; - - } - - /** - * _runSetup() - parse the request to see which setup command to run - * - * @return void - */ - protected function _runSetup() - { - $setupCommand = (isset($_SERVER['argv'][2])) ? $_SERVER['argv'][2] : null; - - switch ($setupCommand) { - case 'storage-directory': - $this->_runSetupStorageDirectory(); - break; - case 'config-file': - $this->_runSetupConfigFile(); - break; - default: - $this->_runSetupMoreInfo(); - break; - } - } - - /** - * _runSetupStorageDirectory() - if the storage directory does not exist, create it - * - * @return void - */ - protected function _runSetupStorageDirectory() - { - $storageDirectory = $this->_detectStorageDirectory(false, false); - - if (file_exists($storageDirectory)) { - echo 'Directory already exists at ' . $storageDirectory . PHP_EOL - . 'Cannot create storage directory.'; - return; - } - - mkdir($storageDirectory); - - echo 'Storage directory created at ' . $storageDirectory . PHP_EOL; - } - - /** - * _runSetupConfigFile() - * - * @return void - */ - protected function _runSetupConfigFile() - { - $configFile = $this->_detectConfigFile(false, false); - - if (file_exists($configFile)) { - echo 'File already exists at ' . $configFile . PHP_EOL - . 'Cannot write new config file.'; - return; - } - - $includePath = get_include_path(); - - $contents = 'php.include_path = "' . $includePath . '"'; - - file_put_contents($configFile, $contents); - - $iniValues = ini_get_all(); - if ($iniValues['include_path']['global_value'] != $iniValues['include_path']['local_value']) { - echo 'NOTE: the php include_path to be used with the tool has been written' . PHP_EOL - . 'to the config file, using ZEND_TOOL_INCLUDE_PATH (or other include_path setters)' . PHP_EOL - . 'is no longer necessary.' . PHP_EOL . PHP_EOL; - } - - echo 'Config file written to ' . $configFile . PHP_EOL; - } - - /** - * _runSetupMoreInfo() - return more information about what can be setup, and what is setup - * - * @return void - */ - protected function _runSetupMoreInfo() - { - $homeDirectory = $this->_detectHomeDirectory(false, false); - $storageDirectory = $this->_detectStorageDirectory(false, false); - $configFile = $this->_detectConfigFile(false, false); - - echo <<_configFile) && $this->_configFile) { - $configOptions['configOptions']['configFilepath'] = $this->_configFile; - } - if (isset($this->_storageDirectory) && $this->_storageDirectory) { - $configOptions['storageOptions']['directory'] = $this->_storageDirectory; - } - - // ensure that zf.php loads the Zend_Tool_Project features - $configOptions['classesToLoad'] = 'Zend_Tool_Project_Provider_Manifest'; - - $console = new Zend_Tool_Framework_Client_Console($configOptions); - $console->dispatch(); - } - - /** - * _logMessage() - Internal method used to log setup and information messages. - * - * @param string $message - * @param bool $storeMessage - * @return void - */ - protected function _logMessage($message, $storeMessage = true) - { - if (!$storeMessage) { - return; - } - - $this->_messages[] = $message; - } - - -} - -if (!getenv('ZF_NO_MAIN')) { - ZF::main(); -} diff --git a/bin/zf.sh b/bin/zf.sh deleted file mode 100644 index f254a891..00000000 --- a/bin/zf.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -############################################################################# -# Zend Framework -# -# LICENSE -# -# This source file is subject to the new BSD license that is bundled -# with this package in the file LICENSE.txt. -# It is also available through the world-wide-web at this URL: -# http://framework.zend.com/license/new-bsd -# If you did not receive a copy of the license and are unable to -# obtain it through the world-wide-web, please send an email -# to license@zend.com so we can send you a copy immediately. -# -# Zend -# Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) -# http://framework.zend.com/license/new-bsd New BSD License -############################################################################# - - -# find php: pear first, command -v second, straight up php lastly -if test "@php_bin@" != '@'php_bin'@'; then - PHP_BIN="@php_bin@" -elif command -v php 1>/dev/null 2>/dev/null; then - PHP_BIN=`command -v php` -else - PHP_BIN=php -fi - -# find zf.php: pear first, same directory 2nd, -if test "@php_dir@" != '@'php_dir'@'; then - PHP_DIR="@php_dir@" -else - SELF_LINK="$0" - SELF_LINK_TMP="$(readlink "$SELF_LINK")" - while test -n "$SELF_LINK_TMP"; do - SELF_LINK="$SELF_LINK_TMP" - SELF_LINK_TMP="$(readlink "$SELF_LINK")" - done - PHP_DIR="$(dirname "$SELF_LINK")" -fi - -"$PHP_BIN" -d safe_mode=Off -f "$PHP_DIR/zf.php" -- "$@" -