Trying to load a sample extension and get error
This is an open discussion with 9 replies, filed under General.
Search
Please can you indent the original post's error output to maintain readability.
Also, we could do with a little more info. What version of Symphony are you running?
Basically, that's how the error was presented to me. No indentation of the code, just the blob. Here is the code from the link I referred to.
I am using Symphony 2.2.5 Thank you,
Should line 24 be:
Frontend::instance()->Page()->registerPHPFunction('hello_world');
I changed the line, but the error still happens. Looks like it doesn't like something at the instance creating time. Thought I could print out the instance created at with "new $classname($param);". In general, do we have a template for extensions? Is site/extensions the only place we put them? How do we separate the ones that we downloaded from the extension site, or created ourselves?
On a similar note, I was trying to enable the "hello world" extension from EXSL function Manager extension, I got a similar error, only without the source code of the extension itself.
Ok, I got my error because I forgot to enclose the PHP code in <?php ... ?>
The "Hello world" example from EXSL function Manager had two bugs: it was missing the closing "?>" at the end and also the class should be renamed from "extension_hello_world
" to "extension_helloworld
"
BTW,
Frontend::instance()->Page()->registerPHPFunction('hello_world');
or
$context['page']->registerPHPFunction('hello_world');
it doesn't make any difference on the final result
it was missing the closing "?>"
It's more secure to omit the ?>
from the end of PHP files.
it doesn't make any difference on the final result
It will from 2.3
onwards as $context['page']->registerPHPFunction('hello_world');
has been deprecated, and will be removed in favour of Frontend::instance()->Page()->registerPHPFunction('hello_world');
. The extension needs updating to reflect this.
Than it boils down to renaming extension_hello_world
to extension_helloworld
to make it work.
As for the other item, I'll use the new API that you mentioned.
Glad it's sorted now.
Create an account or sign in to comment.
I was following "How to Register and Use Custom PHP Functions Inside XSL" example and created my own extension under my-site/extensions/registerphpfunctions/extension.driver.php. Now when I refresh the extensions page under my site it prints an error:
class extensionregisterphpfunctions extends Extension { public function about() { return array( 'name' => 'Register PHP Functions', 'version' => '0.1', 'release-date' => '2010-10-08', 'author' => array( 'name' => '', 'website' => '', 'email' => '' ) ); } public function getSubscribedDelegates(){ return array( array( 'page' => '/frontend/', 'delegate' => 'FrontendOutputPreGenerate', 'callback' => 'registerFunctions' ) ); } public function registerFunctions($context){ $context['page']->registerPHPFunction('helloworld'); } } // Functions to be called by XSL page templates: function helloworld($path){ return "Hello World!"; } Fatal error: Class 'extensionregisterphpfunctions' not found in /home/user/Dev/site.com/symphony/lib/toolkit/class.extensionmanager.php on line 629
The line 629 is "self::$_pool[$name] = new $classname($param);". I printed out the element, looks like it's instantiated. What's missing in this case?