Créer un compte ou loggez-vous pour pouvoir ajouter, commenter et noter les snippets.

Navigation

my Symfony Plugins

Plugins demos


My bookmarks

Vous pouvez commenter/noter en utilisant le compte anonymous (mot de passe: anonymous)
You can comment/rate using the anonymous account (password: anonymous).

[symfony] Joomla to symfony mini-bridge [EN] (deprecated) - 1659 view(s)

This snippet is deprecated, please use the sfJoomla15BridgePlugin plugin witch works with the new 1.5 Joomla and the symfony 1.2 version.


This tutorial is for the 0.7.0 version please check the Symfony Wiki for 0.8.0 doc until i can update this tutorial.

Intro

Well, in fact i have taken the idea from what has already been done with cakePHP, you can find the original blog articles here (1) and thanks to the authors for the work. Now a full project for this purpose is available for cakePHP it is called Jake

(1)

1 - Installation

Versions used :

Now you must have a sfJoomlaBridge dir in your plugins dir and a com_symfony dir in /web/components

The Symfony application is built as usual and the Joomla installation must be achieved in the /web of the Symfony project.

2 - Configuration

Joomla component

Open symfony.html.php, line 8 modify the name of Symfony controller file (frontoffice.php by default). Take care to use a production controller, because we should't have any debug information

Un-comment line 34 with file_get_contents if you don't have curl installed on you web server, and comment the curl related line above.

In index.php of Joomla

before (near line 114)

// mainframe is an API workhorse, lots of 'core' interaction routines
$mainframe = new mosMainFrame( $database, $option, '.' );
$mainframe->initSession();

add

//Before Joomla initialize its mainframe, lets play…
// check missing component — added before $mainframe is being initialized
//##########################
if (!file_exists($mosConfig_absolute_path . '/components/'. $option )) { 
    $option = 'com_symfony';  
    //set component to com_cake if a controller is not found.
}

Symfony

Clear the cache

> symfony clear cc

There is nothing really specific except the new link helper to use in the templates. To use the Joomla helpers :

<?php use_helper('Joomla'); ?>

You can also modify the index file of Joomla application in plugins/sfJoomlaBridge/config/config.php

3 - Use

Creation of Symfony page

We are going to do a page (module/action) whitch will be called by Joomla with the help of its new component.


sf actions creation

Nous are going to create 2 actions, 1 basic (static content) and one with the users list of Joomla administration

index/actions/actions.class.php

/**
     * Executes index action
     */
    public function executeIndex()
    {
    }
 
    /**
     * Test Joomla/Symfony integration
     * 
     * @author lvernet
     * @since  26 feb 2007
     */
    public function executeUsers()
    {
        $this->users = JosUsersPeer::doSelect(new Criteria());
    }


sf view creation

The plugin introduce a new helper link_to_joomla that allows to do link to others symfony pages but with staying in the Joomla application.

templates/usersSuccess.php

<?php use_helper('Joomla'); ?>
 
<h1>Joomla Users list</h1>
<p>This list is retrieved with the help of the ORM of Symfony</p>

  <?php if ($users): ?>   <table class="contenttoc"> <thead> <th>Id</th> <th>Name</th>   <th>User name</th> </thead> <?php foreach($users as $user): ?> <tr> <td><?php echo $user->getId(); ?></td> <td><?php echo $user->getName(); ?></td> <td><?php echo $user->getUsername(); ?></td> </tr> <?php endforeach; ?> </table> <?php endif; ?>  
<?php echo link_to_joomla('Back to index', 'index/index', array('query_string' => 'param1=chat&param2=rat')); ?>

templates/indexSuccess.php

<?php use_helper('Joomla'); ?>
 
<h1>This content is provided through Symfony framework.</h1>
 
<?php echo image_tag('powered_by.png') ?> &&
<?php echo image_tag('http://www.symfony-project.com/images/symfony_logo.gif') ?>
 

<?php echo link_to_joomla('Users list', 'index/users'); ?>

Now we must desactivate the view's layout, because we don't want it as we will use the one of Joomla.

In index/config/view.yml :

indexSuccess:
  has_layout:    off
 
usersSuccess:
  has_layout:    off


Call and test it in Joomla

We can now call our sf pages in Joomla, link are formed as following : index.php?option=index&task=users

Go to the url: http://projectroot/index.php?option=index&task=users, the users list is displayed and you have a link to go to the index page (link created with the joomla helper)

/!\ Be carefull, the option param should not match the name of a Joomla component /!\

4 - Demo

Has to be updated for symfony 1.1

5 - Conclusion

I made this quiet quickly, of course there are lot of things to do to have a perfect integration as the Jake project does it for cakePHP. If someone is interested, feel free to take the code and contribute, it would be nice.

COil :)

par COil le 2008-10-19, taggé : bridge  joomla  plugin  symfony 

Commentaires sur ce snippet

gravatar icon
#1 Martin le 2009-03-04 at 06:49

Hi, I'm using your plugin but I'm having some problems. I need to use Symfony session to store some data on it but can't do it through joomla. Can you suggest something

Thanks a lot Martin Agnese Argentina

gravatar icon
#2 COil (Vernet Loïc) le 2009-03-14 at 02:55

Hi Martin, well i'm sorry but the sfJoomlaBridgePluguin is not up to date and will not be maintained anymore (the 1.0 version is outdated now). You should have a look at the http://www.symfony-project.org/plugins/sfJoomla15BridgePlugin plugin. See

gravatar icon
#3 LaurentG le 2009-08-28 at 05:15

I am interested about using this plugin (in is new version). Is there a more complete example somewhere ? Is there an application in production using this bridge? thanks

gravatar icon
#4 COil le 2009-08-31 at 12:14

Hi LaurentG;

I'm sorry but i won't maintain this plugin anymore, please contact the <a href="http://www.symfony-project.org/plugins/developer/enrique-martinez">lead developper</a>.

See u. ^^

Ajouter un commentaire / Add a comment

Nom / Pseudo : 

Email (gravatar activé/activated) : 

Site Web (facultatif/optional) : 

Commentaire / Comment : (*)

Ecrivez le mot "vache" ci dessous. (Write the word "vache" below) (*)

Debug toolbar