FriendsOfPHP / Goutte

Goutte, a simple PHP Web Scraper
MIT License
9.26k stars 1.01k forks source link

Uncaught Error: Call to undefined method Symfony\Component\DomCrawler\Crawler::closest() #405

Open marcpre opened 4 years ago

marcpre commented 4 years ago

I am using goutte in my composer in my wordpress plugin:

{
  "require": {
    "fabpot/goutte": "^4.0"
  }
}

Furthermore, I am also using the closest() function within my code on this line:

$table = $crawler->filter('.calendarspecs__spec')->first()->closest('table');

When executing the code I get the following error:

PHP Fatal error: Uncaught Error: Call to undefined method Symfony\Component\DomCrawler\Crawler::closest() in /C:/Users/Desktop/Code/wordpress/wp-content/plugins/myPlugin/includes/Parser.php on line 125

Even though the function exists within my vendor folder, I get the above error:

enter image description here

When running composer show i I get:

> composer show -i
You are using the deprecated option "installed". Only installed packages are shown by default now. The --all option can be used to show all packages.
fabpot/goutte                 v4.0.0  A simple PHP Web Scraper
guzzlehttp/guzzle             6.5.2   Guzzle is a PHP HTTP client library
guzzlehttp/promises           v1.3.1  Guzzle promises library
guzzlehttp/psr7               1.6.1   PSR-7 message implementation that also provides common utility methods
psr/container                 1.0.0   Common Container Interface (PHP FIG PSR-11)
psr/http-message              1.0.1   Common interface for HTTP messages
psr/log                       1.1.2   Common interface for logging libraries
ralouphie/getallheaders       3.0.3   A polyfill for getallheaders.
symfony/browser-kit           v4.4.2  Symfony BrowserKit Component
symfony/css-selector          v4.4.2  Symfony CssSelector Component
symfony/dom-crawler           v4.4.2  Symfony DomCrawler Component
symfony/http-client           v4.4.2  Symfony HttpClient component
symfony/http-client-contracts v1.1.8  Generic abstractions related to HTTP clients
symfony/mime                  v4.4.2  A library to manipulate MIME messages
symfony/polyfill-ctype        v1.13.1 Symfony polyfill for ctype functions
symfony/polyfill-intl-idn     v1.13.1 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring     v1.13.1 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72        v1.13.1 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73        v1.13.1 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/service-contracts     v1.1.8  Generic abstractions related to writing services

Any suggestions what I am doing wrong?

I appreciate your replies!