Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: klespios on March 05, 2018, 05:16:00 AM

Title: Use SMF Users in a Symfony website
Post by: klespios on March 05, 2018, 05:16:00 AM
Hello !

I am currently working on a website composed in two parts : One with Symfony (the biggest part of the website) and an other one with SMF.

Because users are already handled with SMF I wanted to use them in the Symfony part. I used this to try : https://wiki.simplemachines.org/smf/How_to_use_the_SMF_user_system_outside_of_SMF

When I add the good require I have an error message :
"Connection Problems
Sorry, SMF was unable to connect to the database. This may be caused by the server being busy. Please try again later."

But when I open the Forum itself it works while it's not the case when I do from my Symfony website.

Here is my test to use "SSI.php" :

<?php



namespace BackOfficeBundle\Controller;



use
BoutiqueBundle\Entity\Produit;
use
BoutiqueBundle\Form\ProduitType;
use
Symfony\Bundle\FrameworkBundle\Controller\Controller;
use
Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use
Symfony\Component\Form\Extension\Core\Type\SubmitType;

require_once
__DIR__."/../../../../../forum/SSI.php";

class
DefaultController extends Controller
{
   
/**
    * @Route("/back_office")
    */
   
public function indexAction()
   {

    if ($context['user']['is_guest'])
{
return $this->render(ssi_login());
}
else
{
           
           
$em = $this->getDoctrine()->getEntityManager();
           
$p = new Produit();
           
$form = $this->createForm(ProduitType::class, $p);

           echo
"dede";
           if (
$form->isSubmitted()) {
               echo
"coucou";
               
$em->persist($p);
               
$em->flush();
           }
           return
$this->render('BackOfficeBundle:Default:index.html.twig', array(
               
'form'=> $form->CreateView()));
           }
   }
}


It'd be very nice if you have any idea,

Thank you in advance,

Klespios

Title: Re: Use SMF Users in a Symfony website
Post by: Kindred on March 05, 2018, 09:38:35 AM
Have you turned OFF local cookies and turned ON sub-domain independent cookies?

Instead of the relative path to SSI with all the ../../.. I recommend using the absolute path.


you didn't globalize $context

I am not certain how the SSI functions will respond to being used within another parser (you call SSI by using a separate function, render
return $this->render(ssi_login());

I am unsure how this will work, if at all...