0

我正在尝试找到一种方法来集成我的网站,使用 Symfony 与我的计费系统WHMCS进行编码。

我尝试的第一件事是创建一个名为 whmcs 的新 symfony 模块,在该模块中,我使用 ob_start/require_once/ob_get_contents 检索页面,但它一直导致空白页面,在日志或其他任何地方都没有任何错误。由于无论如何这将是一场导航噩梦,我放弃了这个想法。

我的第二个想法是利用WHMCS 挂钩系统。到目前为止,除了一件事之外,它起作用了。我不知道如何调用我的 layout.php 文件。这是我当前的代码:

function getSymfonyLayout()
{
    require_once($_SERVER['DOCUMENT_ROOT'].'/../config/ProjectConfiguration.class.php');
    $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
    $context = sfContext::createInstance($configuration);
    $context->getRequest()->setRelativeUrlRoot('');
    $context->getInstance()->getConfiguration()->loadHelpers('Partial');
    echo get_partial("global/header");
}

add_hook("ClientAreaPage",1,"getSymfonyLayout");

我的问题是,虽然标题确实加载了,但没有元,没有 css,没有 javascript。这些设置保存在我的 view.yml 文件中,部分不加载该文件。

我需要找到一种方法来做类似echo get_layout("layout");echo get_methodaction("whmcs", "index");

这可能有点傻,但我一直在浏览 wiki、论坛和我的 symfony 书,但我找不到我需要使用的代码。

4

2 回答 2

3

尝试使用卷曲

$url = 'your symfony url';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$data = curl_exec($ch);
echo $data;

上面的代码向 url 发送 curl 请求$url

$query_string是您将在需要时发布到页面的数据

$query_string = "";
foreach ($postfields AS $k => $v)
    $query_string .= "$k=" . urlencode($v) . "&";

$query_string = trim($query_string, '&');

其中$postfields是要发送的参数数组此外,您可以发送跨域 ajax 请求(如果您使用 jQuery,您只需将$.ajax选项设置dataTypejsonp),这将仅加载操作的内容部分(不包括样式表和 javascript )

于 2012-11-29T10:57:41.527 回答
1

在您的操作方法中,使用:

$output = $this->getController()->getPresentationFor("module", "action");

这会将指定模块和操作的输出渲染到$output; 有关详细信息,请参见http://www.symfony-project.org/api/1_2/sfController#method_getpresentation

于 2010-02-28T12:56:50.667 回答