Search code examples
phpsymfony1whmcs

How to integrate a symfony website with whmcs


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.


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