zoukankan      html  css  js  c++  java
  • 在CI框架中的配置整合amfphp

    之前做的项目用到CI框架和amfphp的整合,主要用于php与flex的交互,在此做一下记录:

    一. 安装CI框架:

    1.  搭建PHP运行环境,本人在WIN7下用WAMP作测试,安装目录:d:/wamp/www

    2.  下载CI框架,在官网http://codeigniter.org.cn/downloads 下载 最新版本,解压打包。

    3.   将CI文件架名称修改为ciamfphp,并存在到d:/wamp/www,开通虚拟域名,

         绑定HOST为: www.ciamfphp.cc,设置好之后访问此域名,如果见到CI框架的欢迎界面,说明搭建CI框架成功。

    二.下载: amfPhp 1.9

         网址:http://downloads.sourceforge.net/project/amfphp/amfphp/amfphp%201.9.zip

    三.配置amfphp

    1. 解压到 d:wampwww 根目录下并重命名为amfphp

    2.将amfphp复制到wampwwwciamfphpapplicationlibraries目录下

    3. 在D:wampwwwciamfphpapplicationlibrariesamfphp下,将amfphp 文件夹中的browser文件夹剪切到D:wampwwwciamfphp根目录下

    4. 打开文件D:wampwwwciamfphpamfphpapplicationcontrollers,在其下建立一个名为amf_gateway.php的控制器:

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    /** 
     * AMFPHP网关接口  
     */
    
    class Amf_gateway extends CI_Controller
    {       
        protected $gateway;           
        protected $amf_path = "libraries/";  //amf中间路径
    
            
         public function __construct()
        {
            parent::__construct();
        }
    
        public function index()
        {
    
           /*
            * ---------------------------------------------------------------
            * 加载AMF框架入口文件
            * ---------------------------------------------------------------
            *
            * 只有index 方法为amf服务入口
            *
            */
            require realpath(APPPATH)."/{$this->amf_path}amfphp/globals.php";
            require realpath(APPPATH)."/{$this->amf_path}amfphp/core/amf/app/Gateway.php";
            define('AMFSERVICES', realpath(APPPATH)."/{$this->amf_path}amfphp/services");
        
            //调用全局验证控制器文件
            require AMFSERVICES.'/Crm_Controller.php';
    
            //实例化 网关
            $this->gateway = new Gateway();
            $this->gateway->setCharsetHandler("iconv", "UTF-8", "UTF-8");
            $this->gateway->setLooseMode();
            $this->gateway->setErrorHandling(E_ALL ^ E_NOTICE);
            $this->gateway->setClassMappingsPath(AMFSERVICES.'/vo'); 
            $this->gateway->setClassPath(AMFSERVICES);
    
            
            //分析错误
            if(PRODUCTION_SERVER)
            {
                //Disable profiling, remote tracing, and service browser
                $this->gateway->disableDebug();
            }
            
            return $this->gateway->service();
          }
          
    }
    
    /* Location: ./application/controllers/amf_gateway.php */

    此时:D:wampwwwciamfphpapplicationlibrariesamfphpgateway.php文件多余,可以删除。

    5. 修改D:wampwwwciamfphp下的.htaccess文件,允许访问browser文件夹

    RewriteEngine on
    RewriteCond $1 !^(index.php|images|browser|robots.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]

    四. 运行amfphp:

    1. 访问 http://www.ciamfphp.cc/amf_gateway/ 

    出现如上提示,则说明设置gateway成功。

    2.  打开D:wampwwwciamfphpapplicationlibrariesamfphpservices文件夹,建立common_controller.php,代码如下:

    //主控制器
    class Common_Controller extends CI_Controller
    { 
        //other code...
    }

    至此,这里就可以做一系列的开发操作了。

    3. 此时访问www.ciamfphp.cc/browser后,点击  “settings”图标,

       设置下:Gateway location为http://www.ciamfphp.cc/amf_gateway/,点击保存就可以操作了

  • 相关阅读:
    mysql 主从配置 读写分离
    interface接口
    http结构
    call_user_func函数
    pcntl_fork 进程
    数据库事务
    php 之 ob缓冲
    shell脚本
    php 守护进程
    ssdb zset
  • 原文地址:https://www.cnblogs.com/whoamme/p/3441161.html
Copyright © 2011-2022 走看看