Permalink
Browse files

Merge branch 'master' of git://github.com/zendframework/zf2

  • Loading branch information...
2 parents 7927a0f + dafaeb3 commit e494b385cea7c3374db1832a6f833e2544a1d8bb @sgehrig sgehrig committed Nov 14, 2010
Showing 1,665 changed files with 33,720 additions and 20,532 deletions.
View
@@ -2,25 +2,23 @@ Welcome to the Zend Framework 2.0.0 Release!
RELEASE INFORMATION
---------------
-Zend Framework 2.0.0dev1
+Zend Framework 2.0.0dev2
THIS RELEASE IS A DEVELOPMENT RELEASE AND NOT INTENDED FOR PRODUCTION USE.
PLEASE USE AT YOUR OWN RISK.
-At this time, we have tested all functionality of Zend\Tool, and followed the
-Quick Start application instructions, and all functionality works as it did in
-the ZF1 series of releases. However, most Zend\Service components have not been
-migrated to namespaces, and Zend\Db has not been completely vetted (in favor of
-doing a complete refactor). Again, please use at your own risk, and be prepared
-for major changes in APIs in the development and alpha milestones prior to the
-first beta release.
-
NEW FEATURES
------------
-Please see the ZF2 Requirements page for details on new features and changes:
+This release concludes two different milestones:
+
+ - Autoloading and Plugin Loading:
+ http://framework.zend.com/wiki/display/ZFDEV2/Zend+Framework+2.0+Milestones#ZendFramework2.0Milestones-Milestone%3AAutoloading%26PluginLoading
+ - Exceptions
+ http://framework.zend.com/wiki/display/ZFDEV2/Zend+Framework+2.0+Milestones#ZendFramework2.0Milestones-Milestone%3AExceptions
- http://framework.zend.com/wiki/display/ZFDEV2/Zend+Framework+2.0+Requirements
+Several components are still in progress, or were skipped due to planned
+rewrites later.
SYSTEM REQUIREMENTS
-------------------
View
@@ -0,0 +1,16 @@
+<?php
+require_once __DIR__ . '/../library/Zend/Loader/ClassMapAutoloader.php';
+$loader = new Zend\Loader\ClassMapAutoloader();
+$loader->registerAutoloadMap(__DIR__ . '/../library/Zend/Controller/.classmap.php');
+$loader->register();
+
+if (!class_exists('Zend\Controller\Action')) {
+ echo "Could not find action class?\n";
+} else {
+ echo "Found action class!\n";
+}
+if (!class_exists('Zend\Version')) {
+ echo "Could not find version class!\n";
+} else {
+ echo "Found version class?\n";
+}
View
@@ -0,0 +1,12 @@
+<?php
+require_once __DIR__ . '/../library/Zend/.classmap.php';
+if (!class_exists('Zend\Controller\Action')) {
+ echo "Could not find action class?\n";
+} else {
+ echo "Found action class!\n";
+}
+if (!class_exists('Zend\Version')) {
+ echo "Could not find version class?\n";
+} else {
+ echo "Found version class!\n";
+}
View
@@ -0,0 +1,147 @@
+<?php
+/**
+ * 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.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @subpackage Exception
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * Generate class maps for use with autoloading.
+ *
+ * Usage:
+ * --help|-h Get usage message
+ * --library|-l [ <string> ] Library to parse; if none provided, assumes
+ * current directory
+ * --output|-o [ <string> ] Where to write autoload file; if not provided,
+ * assumes ".classmap.php" in library directory
+ * --overwrite|-w Whether or not to overwrite existing autoload
+ * file
+ */
+
+$libPath = __DIR__ . '/../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(__DIR__ . '/../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->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 ".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 . '.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 ClassFileLocater, and pass it the library path
+$l = new \Zend\File\ClassFileLocater($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;
+iterator_apply($l, function() use ($l, $map, $strip){
+ $file = $l->current();
+ $namespace = empty($file->namespace) ? '' : $file->namespace . '\\';
+ $filename = str_replace($strip, '', $file->getRealpath());
+
+ $map->{$namespace . $file->classname} = $filename;
+
+ return true;
+});
+
+// Create a file with the class/file map.
+// Stupid syntax highlighters make separating < from PHP declaration necessary
+$content = '<' . "?php\n"
+ . 'return ' . var_export((array) $map, true) . ';';
+
+// Prefix with __DIR__; modify the generated content
+$content = preg_replace('#(=> )#', '$1__DIR__ . DIRECTORY_SEPARATOR . ', $content);
+
+// Write the contents to disk
+file_put_contents($output, $content);
+
+if (!$usingStdout) {
+ echo "Wrote classmap file to '" . realpath($output) . "'" . PHP_EOL;
+}
@@ -0,0 +1,41 @@
+<?php
+/**
+ * createAutoloadTestClasses.php
+ *
+ * A script for creating a hierarchy of classes for use with testing
+ * autoloading. Each directory has classes from a to p; additional classes are
+ * generated 2 levels deep, giving a total of 16^3 classes to use in
+ * autoloading tests.
+ */
+
+function createClasses($depth, $namespace)
+{
+ foreach (range('a', 'p') as $letter) {
+ // Create content for namespaced class
+ $content =<<<EOT
+<?php
+namespace $namespace;
+class $letter { }
+EOT;
+
+ // Write content to disk
+ $dir = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
+ file_put_contents(
+ $dir . DIRECTORY_SEPARATOR . $letter . '.php',
+ $content
+ );
+
+ // If we still have depth, recurse and create more classes using the
+ // current letter as a sub-namespace.
+ if ($depth > 0) {
+ $childDir = $dir . DIRECTORY_SEPARATOR . $letter;
+ mkdir($childDir);
+ createClasses($depth - 1, $namespace . '\\' . $letter);
+ }
+ }
+}
+
+// Use 'test' as the top-level namespace, and set a depth of "2" (will provide
+// 3 levels of classes).
+mkdir('test');
+createClasses(2, 'test');
View
9 bin/zf.php 100755 → 100644
@@ -383,14 +383,14 @@ protected function _setupToolRuntime()
protected function _tryClientLoad()
{
$this->_clientLoaded = false;
- $fh = @fopen('Zend/Loader/Autoloader.php', 'r', true);
+ $fh = @fopen('Zend/Loader/StandardAutoloader.php', 'r', true);
if (!$fh) {
return $this->_clientLoaded; // false
} else {
fclose($fh);
unset($fh);
- include 'Zend/Loader/Autoloader.php';
- $this->_clientLoaded = class_exists('Zend\Loader\Autoloader', false);
+ include 'Zend/Loader/StandardAutoloader.php';
+ $this->_clientLoaded = class_exists('Zend\Loader\StandardAutoloader', false);
}
return $this->_clientLoaded;
@@ -604,7 +604,8 @@ protected function _runTool()
// ensure that zf.php loads the Zend_Tool_Project features
$configOptions['classesToLoad'] = 'Zend\Tool\Project\Provider\Manifest';
- Zend\Loader\Autoloader::getInstance();
+ $autoloader = new Zend\Loader\StandardAutoloader();
+ $autoloader->register();
$console = new Zend\Tool\Framework\Client\Console\Console($configOptions);
$console->dispatch();
Oops, something went wrong.

0 comments on commit e494b38

Please sign in to comment.