在现有页面中嵌入CakePHP

在现有页面中嵌入CakePHP,php,cakephp,routing,embed,Php,Cakephp,Routing,Embed,我自愿创建了一些db应用程序,我告诉那些家伙这将非常简单,因为我想使用CakePHP。可悲的是,过了一段时间,他们告诉我,他们想把它放在已经存在的网络中,这是一个古老的高度定制的PHPNuke 所以我想要的是在一个已经存在的页面中用CakePHP生成一个的内容。我在网上查了一下,但没有找到我要找的东西。我是框架的用户,而不是开发人员,所以我不太了解后端以及MVC框架内部的工作方式(这是我第一次尝试CakePHP,因为我是Rails的家伙) 到目前为止,我所做的是为Cake禁用mod_rewrit

我自愿创建了一些db应用程序,我告诉那些家伙这将非常简单,因为我想使用CakePHP。可悲的是,过了一段时间,他们告诉我,他们想把它放在已经存在的网络中,这是一个古老的高度定制的PHPNuke

所以我想要的是在一个已经存在的页面中用CakePHP生成一个
的内容。我在网上查了一下,但没有找到我要找的东西。我是框架的用户,而不是开发人员,所以我不太了解后端以及MVC框架内部的工作方式(这是我第一次尝试CakePHP,因为我是Rails的家伙)

到目前为止,我所做的是为Cake禁用
mod_rewrite
。在PHPNuke模块中,我包含了Cake的index.php和一个空布局的渲染视图。这在某种程度上是可行的,但问题是如何形成URL。我现在已经可以用了

http://localhost/modules.php/posts?op=modload&name=xxxxx&file=index&do=xxxxx
但有了这个,所有链接到CSS和PHPNuke网站上的图像都被破坏了

有没有什么方法可以使用

http://localhost/modules.php?op=modload&name=xxxxx&file=index&do=xxxxx&CakePHP=/posts/bla/bla
或者其他任何可以完成这项工作的方法?我真的不想改变现有PHPNuke应用程序中的任何内容


非常感谢

如果您不了解CakePHP是如何工作的,您将很难做您想做的事情,因为这将意味着对CakePHP核心文件进行黑客攻击以绕过默认路由。这基本上意味着您将按照CakePHP的工作方式重新工作,因此您可以忘记更新到更新的CakePHP版本,维护将是地狱

如果您想修改系统,但保留PHP Nuke,我建议不要在其中干扰CakePHP,因为这会带来太多问题,无法事先预测

我认为你的选择如下:

  • 了解PHP Nuke是如何工作的,以便您可以修改它
  • 对页面使用常规php

  • 与您想要做的事情相比,这两种方法在数量级上都更简单。

    所以总结一下我发现的解决方案,如果有人会寻找类似的方法。通过使用两个自定义管线类()解决的问题

    然后在php中进行简单的配置

    App::import('Lib', 'CustomParserRoute'); 
    App::import('Lib', 'CustomMatcherRoute');  
    
    // entry point to custom routing, if route starts with modules.php it matches 
    // the url and CustomParserRoute::parse class is called
    // and route from query string is processed      
    Router::connect('/modules.php', array('controller' => 'my_controller'), array('routeClass' => 'CustomParserRoute'));
    
    // actual routes used by cakephp app, usual routes that need to use 
    // CustomMatcherRoute classe, so when new url is generated, it is modified 
    // to be handled later by route defined above.
    Router::connect('/my_controller/:action/*', array('controller' => 'my_controller'), array('routeClass' => 'CustomMatcherRoute'));     
    

    谢谢,PHPNUKE几乎和普通的PHP一样,没有MVC、ORM、CRUD,而且很可怕:-)看起来像是两个简单的自定义CakePHP路由类([link])完成了这项工作。理论上,在简单的测试用例中,它是可以工作的,所以希望在其他任何情况下都能工作。有趣的是,感谢您分享您的解决方案:)希望它在其他情况下也能工作。
    App::import('Lib', 'CustomParserRoute'); 
    App::import('Lib', 'CustomMatcherRoute');  
    
    // entry point to custom routing, if route starts with modules.php it matches 
    // the url and CustomParserRoute::parse class is called
    // and route from query string is processed      
    Router::connect('/modules.php', array('controller' => 'my_controller'), array('routeClass' => 'CustomParserRoute'));
    
    // actual routes used by cakephp app, usual routes that need to use 
    // CustomMatcherRoute classe, so when new url is generated, it is modified 
    // to be handled later by route defined above.
    Router::connect('/my_controller/:action/*', array('controller' => 'my_controller'), array('routeClass' => 'CustomMatcherRoute'));