user3237524
user3237524

Reputation: 7

How to change guzzle properties from goutte?

<?php
require_once '/var/www/goutte.phar';
 use Goutte\Client; 


 $guzzle = parent::getClient(); //You'll want to pull the Guzzle client out of Goutte to inherit its defaults
$guzzle->setDefaultOption('verify', '/path/to/cacert.pem'); //Set the certificate at @mtdowling recommends
$client->setClient($guzzle); //Tell Goutte to use your modified Guzzle client 

$crawler = $client->request('GET', 'https://ocean.ac-guadeloupe.fr/publinet/resultats'); //Proceed as you were
var_dump($crawler);
?>

When i run the above code I get the error "Cannot access parent:: when no class scope is active". So how to access Guzzle properties from Goutte?

Upvotes: 0

Views: 1130

Answers (1)

John C
John C

Reputation: 8415

The start of the sample seems to assume you are writing an extension of the Goutte Client class. If you are just using the class, the snippet is more like:

$client = new Client();
$guzzle = $client->getClient(); //You'll want to pull the Guzzle client out of Goutte to inherit its defaults

$guzzle->setDefaultOption('verify', '/path/to/cacert.pem'); //Set the certificate at @mtdowling recommends
$client->setClient($guzzle); //Tell Goutte to use your modified Guzzle client 

$crawler = $client->request('GET', 'https://ocean.ac-guadeloupe.fr/publinet/resultats'); //Proceed as you were
var_dump($crawler);

Upvotes: 0

Related Questions