我想我的生活需要新的挑战

zf2整个框架里面都应用了namespace,并且他的每个模块,我们都可以根据自己的需要去命名路径,对我来说,zf2的模块化更加的清晰,对于外包来说,或许很方便.

zendframework 2

创建他,我就不说过程了,我按照自己的理解说说运行的步骤吧

View文件夹里面存放的是视图,

module:里面存放的是我们的模块,每一个模块都可以单独一个文件夹,当我们d调用模块的时候,会先找到moudel.php,--->config/module.config.php去配置相应的信息

 1 /**
 2  * This autoloading setup is really more complicated than it needs to be for most
 3  * applications. The added complexity is simply to reduce the time it takes for
 4  * new developers to be productive with a fresh skeleton. It allows autoloading
 5  * to be correctly configured, regardless of the installation method and keeps
 6  * the use of composer completely optional. This setup should work fine for
 7  * most users, however, feel free to configure autoloading however you'd like.
 8  */
 9 
10 // Composer autoloading
11 if (file_exists('./vendor/autoload.php')) {
12     $loader = include './vendor/autoload.php';
13 }
14 
15 $zf2Path = false;
16 
17 if (is_dir('./vendor/Zend')) {
18     $zf2Path = './vendor/Zend';
19 } elseif (getenv('Zend_PATH')) {      // Support for Zend_PATH environment variable or git submodule
20     $zf2Path = getenv('Zend_PATH');
21 } elseif (get_cfg_var('zend_path')) { // Support for zend_path directive value
22     $zf2Path = get_cfg_var('zend_path');
23 }
24 if ($zf2Path) {
25     if (isset($loader)) {
26         $loader->add('Zend', $zf2Path);
27     } else {
28         include $zf2Path . '/Loader/AutoloaderFactory.php';
29         Zend\Loader\AutoloaderFactory::factory(array(
30             'Zend\Loader\StandardAutoloader' => array(
31                 'autoregister_zf' => true
32             )
33         ));//自动加载
34     }
35 }
36 
37 if (!class_exists('Zend\Loader\AutoloaderFactory')) {
38     throw new RuntimeException('Unable to load Zend. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
39 }
init_autoload.php

相关文章: