安装Zend Framework
来源:互联网 发布:java待遇 编辑:程序博客网 时间:2024/05/17 02:17
this is my understanding now , there maybe some incorrectness in it , but i will be back to verify them soon after i find them.
first time to install the new Zend Framework,it seem really intermediate at first with all the tools: git, composer..., but i saw somewhere else say all you have to do is just download the Zend library and throw it in the php include_path dir , so i spend two days to figure it out what it takes to install the Zend Framework, here is what i found so far, stay tuned , it just get started.
bottom line, you can just throw the Zend library and with some code , you are ready to go, no git, no composer and no complicate classes.
all the composer did for you is set up the auto_load function,the custom auto_load function has following rules:
1 if it is in the zend namespace it will look in to the 'Zend' library(in the default case it is thevendor/zenframework/zendframework/library)
2 else it will look in a fallback dir you provided
3 else it will look in the php inlcude_path
what we want to achieve is let Zend look in the php include_path,to allow this we have to set up the our own autoload function. here is the tricky part , usually we wil provide the class name like this someNamespace_somesubNamespace_classname,but in the index.php you can see that it use the "Zend\Mvc\Application" syntax, we have to have some code to counter this ,here is a custom autoload function that works(i copy most of the code from the code that is generated by composer):
function myownClassloader($class){ 10 if (false !== $pos = strrpos($class, '\\')) { 11 // namespaced class name 12 $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($clas s, 0, $pos)) . DIRECTORY_SEPARATOR; 13 $className = substr($class, $pos + 1); 14 } else { 15 // PEAR-like class name 16 $classPath = null; 17 $className = $class; 18 } 19 20 $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '. php'; 21 22 if($file = stream_resolve_include_path($classPath)){ 23 include($file); 24 } 25 }now all you have to do is register the function with the spl_autoload_register() function and you are ready to go .
notes:
1 most of the custom autoload function is dealing with path
2 here is the full code of the modified /public/index.php
<?php/** * This makes our life easier when dealing with paths. Everything is in the php include_path now */// Setup autoloadingchdir(dirname(__DIR__)); //we still need to find the config file "config/application.config.php"function myownClassloader($class){if (false !== $pos = strrpos($class, '\\')) { // namespaced class name $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR; $className = substr($class, $pos + 1); } else { // PEAR-like class name $classPath = null; $className = $class; } $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';if($file = stream_resolve_include_path($classPath)){include($file);}}spl_autoload_register('myownClassloader');
- 安装Zend Framework
- 配置安装zend Framework
- Zend FrameWork 安装配置
- Zend Framework安装
- Zend Framework 1 安装配置
- ubuntu下安装zend-framework
- zend framework 2f安装
- Zend Framework框架安装准备
- Apache下Zend Framework的安装
- centos 下zend framework安装手册
- Zend Framework介绍与安装配置
- 【转】 [Ubuntu] lampp安装Zend Framework
- Xampp环境下安装zend framework
- Zend Framework介绍与安装配置
- 安装zend framework开发工具“ZF tool”
- zend framework
- Zend Framework
- Zend Framework
- 求最长重复子串(后缀数组)
- error c3872: “0x3000”: 此字符不允许在标识符中使用
- android面试题总结加强再加强版(一)
- zombie process
- Linux中与进程终止相关的信号SIGTERM,SIGKILL,SIGINT
- 安装Zend Framework
- android面试题总结加强再加强版(二)
- android面试题总结加强再加强版(三)
- ORACLE查看修改oracle字符集
- android面试题总结加强再加强版(四)
- session marked for kill
- 用Matlab编写GEP程序
- 串口配置
- 查看oracle数据库中空间索引