1

Im trying to run Symfony Crawler in my script, but when I try to do that, I get 500 server error. Where is the problem? The code:

use Symfony\Component\DomCrawler\Crawler;

class Yt_downloader
{
    private $__parser;
    private $__uri;

    public function __construct($cfg)
    {
        $this->__parser = new Crawler();

        if ( is_array($cfg) ) {
            foreach ( $cfg as $key => $value ) {
                $this->{$key} = $value;
            }
        }
    }

    public function test()
    {
        print_r($this->__uri);
    }
}

and the action:

    require_once APPPATH . 'libraries/Yt_downloader.php';
    $downloader = new Yt_downloader(array(
        '__uri' => 'https://www.youtube.com/watch?v=...'
    ));

btw, my composer.json:

    {
  "name": "project",
  "description": "",
  "license": "MIT",
  "require-dev": {
    "symfony/css-selector": "~2.8|~3.0"
  },
  "suggest": {
    "symfony/css-selector": ""
  },
  "autoload": {
    "psr-4": { "Symfony\\Component\\DomCrawler\\": "" }
  },
  "minimum-stability": "dev",
  "extra": {
    "branch-alias": {
      "dev-master": "3.0-dev"
    }
  }
}

this is being used in Codeigniter project. I thought it can be composer problem, but when I try to use different library it works. I think there is a problem with namespaces or something. Maybe I can see log anywhere? I use ubuntu..

2
  • Can you post the 500 error message? Commented Oct 18, 2015 at 20:29
  • I just debugged it and I see that class Crawler is not found. Then I found, that it should be stored in Components directory, which is not found in my vendor/symfony/ folder.. but the next question would be - how to download crawler components Commented Oct 18, 2015 at 20:36

1 Answer 1

1

You need to require

"symfony/dom-crawler": "~2.8|~3.0"

In your composer.json file so that the crawler component is installed

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.