Question

I'm trying to find a way to integrate my website, coded using Symfony with my billing system, WHMCS.

The first thing I tried was creating a new symfony module called whmcs and in that module, I was using ob_start/require_once/ob_get_contents to retreive the page but it kept resulting in a blank page, without any error in the logs or anywhere else. Since this was going to be a navigation nightmare anyway, I gave up on that idea.

My second idea was to take advantage of the WHMCS hooks system. So far, it worked except for one thing. I have no idea how to call my layout.php file. Here is my current code:

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");

My issue here is that, while the header does load, there is no meta, no css, no javascript. Those settings are saved in my view.yml file and partials don't load that file.

I need to find a way to do something like echo get_layout("layout"); or echo get_methodaction("whmcs", "index");

It's probably something silly but I've been going thru wikis, forums and my symfony book and I just can't find the code I need to use.

Was it helpful?

Solution

In your action method, use:

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

This will render the output of the specified module and action into $output; see http://www.symfony-project.org/api/1_2/sfController#method_getpresentationfor for details

OTHER TIPS

Try to use curl

$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;

The code above sends a curl request to the url $url

$query_string is the data you are going to post to the page if needed

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

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

where $postfields is an array of the parameters to send Additionally you can send a cross domain ajax request (if you're using jQuery you just set the $.ajax option dataType to jsonp) and that would load only the content part of the action (stylesheets and javascripts are not included)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top