Ask your Symfony questions! Pay money and get answers fast! (more info)

Installing sfJqueryTreeDoctrineManagerPlugin to Symfony 1.4 Symfony

  • SOLVED

I have faced serious difficulties while installing sfJqueryTreeDoctrineManagerPlugin to Symfony 1.4 w/ Doctrine ORM. The installation directly from the server did not work out like with previous plugins that I have installed:

<blockquote>C:\path>symfony plugin:install sfJqueryTreeDoctrineManagerPlugin
plugin installing plugin "sfJqueryTreeDoctrineManagerPlugin"

No release available for plugin "sfJqueryTreeDoctrineManagerPlugin"</blockquote>

This is why I needed to install the plugin by downloading the tgz-archive and install it manually like this:
<blockquote>
C:\path>symfony plugin:install "C:\path\to\downloads\sfJqueryTreeDoctrineManagerPlugin-1.2.4.tgz"
plugin installing plugin "C:\path\to\downloads\sfJqueryTreeDoctrineManagerPlugin-1.2.4.tgz"

sfSymfonyPluginManager Installing web data for plugin</blockquote>

I guess everything should be fine this far?

After that I edited \apps\admin\config\settings.yml like instructed in the plugins readme file.

all:
.settings:
enabled_modules: [default, sfJqueryTreeDoctrineManager]


I also checked that the plugin was enabled in \config\ProjectConfiguration.class.php like this:

$this->enablePlugins(array(
// other plugins,
'sfJqueryTreeDoctrineManagerPlugin'
));


I published assets and cleared cache:

<blockquote>C:\path>symfony plugin:publish-assets
>> plugin Configuring plugin - sfJqueryTreeDoctrineManagerPlugin
C:\path>symfony cc</blockquote>

Finally I added the required helper to the newly created apps\admin\modules\category\templates\indexSuccess.php

<?php
use_helper("sfJqueryTreeDoctrine");
echo get_nested_set_manager("Category", "name");


When loading the page I unfortunately get the following error:

<blockquote><strong>500 | Internal Server Error | InvalidArgumentException</strong>
Unable to load "sfJqueryTreeDoctrineHelper.php" helper in: SF_ROOT_DIR\apps\admin\modules/businessunitgroup/lib/helper, SF_ROOT_DIR\apps\admin\lib/helper, SF_ROOT_DIR\lib/helper, SF_SYMFONY_LIB_DIR/helper.</blockquote>

The file sfJqueryTreeDoctrineHelper.php exists indeed but not in any previously mentioned folder. The file can only be found in the folder \plugins\sfJqueryTreeDoctrineManagerPlugin\lib\helper. I guess that Symfony doesn't look to that folder while finding helpers?

I have tried to move the helper file to one of the previously mentioned folders. As expected, that changes the error. Now I get:

<blockquote><strong>500 | Internal Server Error | sfConfigurationException</strong>
The component does not exist: "sfJqueryTreeDoctrineManager", "manager".</blockquote>

Unfortunately I can't figure out how should I be able to retrieve the "missing" component from the correct folder.

I would be very grateful for any advice to help me forward.

By the way, I am aware that there are other nested-set / tree plugins available for Symfony (like sfDoctrineTreePlugin and caPropelTreePlugin) but unluckily those are either uncompatible or too limited for my needs.

Answers (3)

2010-06-03

Martin Palacio answers:

What version of Windows are you using? Maybe it's a permissions issue, or a path-using-spaces one. Try to uninstall the plugin, move the tgz to your project folder and install it again.
BTW what is your SF_ROOT_DIR?

EDIT: I confirm that the plugin works on Ubuntu (installing the tgz as you did), but I slightly modified the part where the plugins are enabled:


//ProjectConfiguration.class.php
$this->enablePlugins('foo', 'bar', 'sfJqueryTreeDoctrineManagerPlugin');

//instead of
$this->enablePlugins(array('foo', 'bar', 'sfJqueryTreeDoctrineManagerPlugin'));


Christine Q. comments:

Thank you for your quick response.

I use Windows XP as a normal user. I guess permission issue can be excluded, because I have granted myself full rights to the project folder (when I was logged in as an administrator). The project folder path (C:\svn\projectname) does not contain any spaces. That is the folder containing all the subfolders like apps, config, data, lib, plugins etc.

Symfony itself is installed to C:\Program Files\BitNami WAPPStack\php\PEAR\symfony. That folder contains the subfolders like action, addon, autoload, cache, command etc. I realize this isn't the recommended way to install Symfony, but as part of a team I didn't make the decision myself. This means that Symfony's install path itself contains spaces. I hope this answered your question about SF_ROOT_DIR.

I restored the project from SVN repository to a state before any sfJqueryTreeDoctrineManagerPlugin install attempts. Then I moved the plugin tgz-archive to C:\svn\projectname and installed it similarly like before:

<blockquote>symfony plugin:install sfJqueryTreeDoctrineManagerPlugin-1.2.4.tgz</blockquote>

This time, however, I got a little different response (the bolded line wasn't there last time):

<blockquote>C:\path>symfony plugin:install sfJqueryTreeDoctrineManagerPlugin-1.2.4.tgz
>> plugin installing plugin "sfJqueryTreeDoctrineManagerPlugin-1.2.4.tgz"
<strong>>> sfSymfonyPluginManager Installation successful for plugin "sfJqueryTreeDoctri
neManagerPlugin-1.2.4.tgz"</strong>
>> sfSymfonyPluginManager Installing web data for plugin</blockquote>

After that I used my TortoiseSVN client to compare, which files were installed. You can find the complete listing at http://pastebin.com/raw.php?i=ub1gMJ8V

As you can see, the plugin extracted its files only to folders plugins/ and web/. Should it maybe have extracted something to some lib/ or helper/ folder?

I also modified the ProjectConfiguration.class.php like you instructed but there was no effect with this plugin. However my previously installed plugins <em>(sfDoctrinePlugin, sfDoctrineGuardPlugin, sfFormExtraPlugin, sfFormI18nNumberPlugin)</em> continued working as usual.


Martin Palacio comments:

Thank you for the detailed explanation. Your installation seems to be OK.
Can you paste the full content of your ProjectConfiguration.class.php?


Martin Palacio comments:

I have some more thoughts.

First of all, be sure that your plugin is loaded.
<blockquote>
//in ProjectConfiguration.class.php
$this->enablePlugins('sfPropelPlugin', 'sfDoctrinePlugin', 'sfJqueryTreeDoctrineManagerPlugin');

die(print_r($this->getPlugins()));

</blockquote>

this helped me sometimes:

<blockquote>when everything fails, just clear the cache manually (delete everything under your /cache folder)</blockquote>


Martin Palacio comments:

I have some more thoughts.

First of all, be sure that your plugin is loaded.
<blockquote>
//in ProjectConfiguration.class.php
$this->enablePlugins('sfPropelPlugin', 'sfDoctrinePlugin', 'sfJqueryTreeDoctrineManagerPlugin');

die(print_r($this->getPlugins())); //add this line and look for the result

</blockquote>

this helped me sometimes:

<blockquote>when everything fails, just clear the cache manually (delete everything under your /cache folder)</blockquote>


Christine Q. comments:

Thank you for your suggestions. I already came home from work and I don't have the installation available here at home. I'll get back to work in 13.5 hours from now, so I'll try your suggestions then and let you know.


Christine Q. comments:

My ProjectConfiguration.class.php looks like this:

<?php

require_once 'C:\\Program Files\\BitNami WAPPStack\\php\\PEAR\\symfony/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();

class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins('sfDoctrinePlugin',
'sfJqueryTreeDoctrineManagerPlugin',
'sfDoctrineGuardPlugin',
'sfFormExtraPlugin',
'sfFormI18nNumberPlugin');
#die(print_r($this->getPlugins())); //add this line and look for the result
}
}


The plugin seems to be loaded:

<blockquote>C:\svn\projectname>symfony cc
Array
(
[0] => sfDoctrinePlugin
[1] => sfJqueryTreeDoctrineManagerPlugin
[2] => sfDoctrineGuardPlugin
[3] => sfFormExtraPlugin
[4] => sfFormI18nNumberPlugin
)</blockquote>

2010-06-03

José Antonio answers:

Hello Cristine Q.

I never used the sfJqueryTreeDoctrineManagerPlugin but here you have an advised.

Try to put the following code in the setup() function inside the sfJqueryTreeDoctrineManagerPluginConfiguration class:


class sfJqueryTreeDoctrineManagerPluginConfiguration extends sfPluginConfiguration
{
const VERSION = '1.0.0-DEV';

//You should write this code here....
public function setup(){
$this->initializeAutoload();
}
}


Like this you are forcing the plugin to load its own lib's classes, for that you can call the get_nested_set_manager($model, $field, $root = 0) function whitout include the sfJqueryTreeDoctrineHelper, this is not the best way to solved the problem but meabe help us.

Also check that you \apps\admin\config\settings.yml have the correct format, I don't think that have to see with you problem but you should check this...


all:
.settings:
enabled_modules: [default, sfJqueryTreeDoctrineManager]


I hope that can help you.

Regards


Christine Q. comments:

Thank you for your response.

The file \plugins\sfJqueryTreeDoctrineManagerPlugin\config\sfJqueryTreeDoctrineManagerPluginConfiguration.class.php looked originally like this (comments stripped away of course):

<?php
class sfJqueryTreeDoctrineManagerPluginConfiguration extends sfPluginConfiguration
{
const VERSION = '1.0.0-DEV';

public function initialize()
{
}
}


I tried to replace the original initialize() function with the setup() function that you proposed like this:

<?php
class sfJqueryTreeDoctrineManagerPluginConfiguration extends sfPluginConfiguration
{
const VERSION = '1.0.0-DEV';

public function setup(){
$this->initializeAutoload();
}
}


Then I tried to append your function after the original one:

<?php
class sfJqueryTreeDoctrineManagerPluginConfiguration extends sfPluginConfiguration
{
const VERSION = '1.0.0-DEV';

public function initialize()
{
}

public function setup(){
$this->initializeAutoload();
}
}


I even tried to modify the original function like this:

<?php
class sfJqueryTreeDoctrineManagerPluginConfiguration extends sfPluginConfiguration
{
const VERSION = '1.0.0-DEV';

public function initialize()
{
$this->initializeAutoload();
}
}


None of these had any effect. Of course I cleared the cache between every step with <strong>symfony cc</strong>. Every try resulted in the same old:

<blockquote><strong>500 | Internal Server Error | InvalidArgumentException</strong>
Unable to load "sfJqueryTreeDoctrineHelper.php" helper in: SF_ROOT_DIR\apps\kassapp\modules/businessunitgroup/lib/helper, SF_ROOT_DIR\apps\kassapp\lib/helper, SF_ROOT_DIR\lib/helper, SF_SYMFONY_LIB_DIR/helper.</blockquote>

I double checked the file \apps\admin\config\settings.yml for correct format and yes, it is okay. Also my previously installed plugins work.


José Antonio comments:

Hi again,

Please after alter the code:


<?php

class sfJqueryTreeDoctrineManagerPluginConfiguration extends sfPluginConfiguration

{

const VERSION = '1.0.0-DEV';



public function initialize()

{

}



public function setup(){

$this->initializeAutoload();

}

}


try to call the helper "get_nested_set_manager" in you template (apps\admin\modules\category\templates\indexSuccess.php) like I show you below:


<?php

// use_helper("sfJqueryTreeDoctrine"); -- Dont use this code....

echo get_nested_set_manager("Category", "name");


Christine Q. comments:

I updated both files as you instructed. Unfortunately I get now only this:

<blockquote><strong>Fatal error:</strong> Call to undefined function get_nested_set_manager() in <strong>C:\svn\projectname\apps\admin\modules\category\templates\indexSuccess.php</strong> on line <strong>5</strong></blockquote>


José Antonio comments:

Hi Christine Q:

I install the plugin in my environment and work correctly. I suggest you you check the follow steps, and meabe can find where is the problem by you own.

1. Copy a folder whit the name "sfJqueryTreeDoctrineManagerPlugin" in the plugins directory of your project. Inside are the plugin's folders. (config, lib, etc...).
2. Enable module sfJqueryTreeDoctrineManager in your settings.yml application config file. The same application where you are used the tree.
3. Run the "symfony plugin:publish-assets" task.
4. If you don't have in your project config file the lines (ProjectConfiguration.class.php)
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enableAllPluginsExcept(array('...', '...'));
}
}

then enable the plugin
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins(array('sfJqueryTreeDoctrineManagerPlugin'));
}
}

5. Include the helper in you template:
<?php
use_helper("sfJqueryTreeDoctrine");

echo get_nested_set_manager("Category", "name");
?>

6. Clear cache.
7. Run the action in the browser.

If all this features are OK and the problem persists, then try to access to the configuration of the halpers path to check if the route of the helpr plugin dir are loaded:
//try to put this code in the template...
print_r(sfContext::getInstance()->getConfiguration()->getHelperDirs());exit;
use_helper("sfJqueryTreeDoctrine");
echo get_nested_set_manager("Category", "name");

then you execute this in the browser, look if in the array exist this address:

Array
(
[0] => ...
[3] => %SF_ROOT_DIR%/plugins/sfJqueryTreeDoctrineManagerPlugin/lib/helper
[4] => ...
)

If this address no apear, then you know what is the real problem....
Regards.


Christine Q. comments:

Thank you for your suggestions. I already came home from work and I don't have the installation available here at home. I'll get back to work in 13.5 hours from now, so I'll try your suggestions then and let you know.


Christine Q. comments:

Looks like we have made some good advance and found the issue. I followed the steps you proposed but with no luck.

When adding print_r(sfContext::getInstance()->getConfiguration()->getHelperDirs());exit; to indexSuccess.php template I get the following:

Array
(
[0] => C:\svn\kassa\apps\kassapp\lib/helper
[1] => C:\svn\kassa\lib/helper
[2] => C:\Program Files\BitNami WAPPStack\php\PEAR\symfony/helper
)


As you can see, the required helper plugin dir doesn't get loaded. This seems to be the real problem.

I already tried to google how to manually add helper directories but with no success. Can you give any advice?


José Antonio comments:

Hello Christine Q.

At this moment, I think that you problems should be in the plugin's instalation. Maybe for installing from svn or any other reason. Please, try to install the plugins from .tar.gz compress files and then make a short degug, to see the behavior of yours plugins.

In sfProjectConfiguration class, find the getPluginSubPaths($subPath = '') function, around the line #418. And put this code here:

//File in %symfony_lib%/config/sfProjectConfiguration.class.php
public function getPluginSubPaths($subPath = '')
{
if (array_key_exists($subPath, $this->pluginPaths))
{
<strong>print_r($this->pluginPaths[$subPath]);exit; // 01</strong>
return $this->pluginPaths[$subPath];
}
$this->pluginPaths[$subPath] = array();
$pluginPaths = $this->getPluginPaths();
<strong>print_r($pluginPaths); // 02</strong>
foreach ($pluginPaths as $pluginPath)
{
if (is_dir($pluginPath.$subPath))
{
$this->pluginPaths[$subPath][] = $pluginPath.$subPath;
}
}
<strong>print_r($pluginPath.$subPath);exit; // 03</strong>
return $this->pluginPaths[$subPath];
}


Inspects the result, you should obtain in <strong>02</strong> the paths of all the installed plugins. In <strong>03</strong> the paths to the plgin's helpers directories. And <strong>01</strong> should not be printed.

If this are Ok, then must search other posible solutions.

<strong>Important:</strong> All this changes should be deleted at the end of the "degub".
Regards.


José Antonio comments:

Sorry, the las line code should are:

public function getPluginSubPaths($subPath = '')
[ ... ]
print_r($this->pluginPaths[$subPath]);exit; // 03
return $this->pluginPaths[$subPath];
}


Regardas.


Christine Q. comments:

I installed the plugin from tgz-archive and did the debug as you instructed. Here is the result:

Array
(
[0] => C:/Program Files/BitNami WAPPStack/php/PEAR/symfony/plugins/sfDoctrinePlugin
[1] => C:/svn/kassa/plugins/sfDoctrineGuardPlugin
[2] => C:/svn/kassa/plugins/sfFormExtraPlugin
[3] => C:/svn/kassa/plugins/sfFormI18nNumberPlugin
)

Array
(
)


So looks like the plugin path isn't found at all? And neither any helper directories? That's very strange, because when I run the command <strong>symfony plugin:list</strong> I get it listed:

<blockquote>C:\path>symfony plugin:list
Installed plugins:
sfJqueryTreeDoctrineManagerPlugin 1.2.4-stable # pear.symfony-project.com (symfony)
symfony 1.4.4-stable # pear.symfony-project.com (symfony)
sfDoctrineGuardPlugin 4.0.1-stable # plugins.symfony-project.org (symfony-plugins)
sfFormExtraPlugin 1.1.1-stable # plugins.symfony-project.org (symfony-plugins)</blockquote>


José Antonio comments:

Sorry for being so persistent, but are you sure that the plugin directory's name is "<strong>sfJqueryTreeDoctrineManagerPlugin</strong>" (without anything else like version number or another thing) and this is the same name of you have in you ProjectConfiguration in the setup function?.
Because Symfony load the plugins automatically looking for in the plugins folder and load all the folders than finish its name in *Plugin, then match this with the enables plugins on the project function setup().

Maybe any name problem cause this issue.
Regards


Christine Q. comments:

I double checked the both file names and they were exactly the same.

It is useful information that Symfony loads the plugins automatically looking for in the plugins folder. Do you know whether it can manually adjusted?


José Antonio comments:

If you look for the function getAllPluginPaths() in the sfProjectConfiguration class, u can see like the plugins path are added to the array with address.
This function must not fail, maybe u can do some alternative solution, but the real cause still are a mistery.


José Antonio comments:

Try a manual plugin load of this way. Put this code at the end (but inside it)
of the class ProjectConfiguration of your project in config folder:

<?php

require_once '...\lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();

class ProjectConfiguration extends sfProjectConfiguration
{

//... Other code...

public function getAllPluginPaths(){
$pluginPaths = parent::getAllPluginPaths();
if(!isset($pluginPaths['sfJqueryTreeDoctrineManagerPlugin'])){
$pluginPaths['sfJqueryTreeDoctrineManagerPlugin'] = sfConfig::get('sf_plugins_dir').'/sfJqueryTreeDoctrineManagerPlugin';
}
return $pluginPaths;
}
}


This should load your plugin, at least still you find the real issue.
Regards.

2010-06-03

Juan Guillermo García answers:

Try installing plugin version 1.2.2 which is compatible with sf1.4 also. I tried in windows and it works fine except for re-creating "category" class (model structure) when I call <em>get_nested_set_manager</em> helper function. Maybe is a version Issue. Normally when you autoload plugin at bootstrap application procedure it uses <plugin_folder>/helper root to load plugin helpers.


Christine Q. comments:

Thank you for your suggestions. I already came home from work and I don't have the installation available here at home. I'll get back to work in 13.5 hours from now, so I'll try your suggestions then and let you know.