Here is a basic example of how simple_html_dom works in a standalone php file.
test.php:
include ('simple_html_dom.php');
$url = "http://www.google.com";
$html = new simple_html_dom();
$html->load_file($url);
print $html;
If I execute it with the command: php test.php
It dumps correctly the html of the website (in this example, google.com)
Now let's take a look at a basic example of code using a Symfony task:
class parserBasic extends sfBaseTask {
public function configure()
{
$this->namespace = 'parser';
$this->name = 'basic';
}
public function execute($arguments = array(), $options = array())
{
$url = "http://www.google.com";
$html = new simple_html_dom();
$html->load_file($url);
print $html;
}
}
This file it's located under: <appname>/lib/task
I don't need to include the library in the file because being under the lib/task folder, it gets automatically loaded.
I execute the task using this command: php symfony parser:basic
And I get the following error message:
PHP Fatal error:
Call to a member function innertext() on a non-object in
/home/<username>/<appname>/lib/task/simple_html_dom.php on line 1688
Any suggestions?