pact-foundation/pact-php
PHP implementation of the Pact consumer-driven contract testing framework. Define contracts between services, run provider verification, and integrate with PHPUnit/CI to prevent breaking API changes. Supports HTTP interactions, mock servers, and Pact Broker workflows.
This is because you install Pact-PHP in one environment, then share/mount the project to other environment and use it, like virtual machine or container.
[FFI\Exception] Failed loading 'vendor/pact-php/bin/pact-ffi-lib/pact.so'
composer install or composer updateFFI\Exception: Failed loading 'vendor/pact-php/bin/pact-ffi-lib/pact.so' (/lib/x86_64-linux-gnu/libc.so: invalid ELF header)
rm vendor/pact-php/bin/pact-ffi-lib/pact.so, then install again with composer install or composer updateThere are several ways to print the logs:
You can run these code (once) before running tests:
use PhpPact\Log\Logger;
use PhpPact\Log\Enum\LogLevel;
use PhpPact\Log\Model\File;
use PhpPact\Log\Model\Buffer;
use PhpPact\Log\Model\Stdout;
use PhpPact\Log\Model\Stderr;
$logger = Logger::instance();
$logger->attach(new File('/path/to/file', LogLevel::DEBUG));
$logger->attach(new Buffer(LogLevel::ERROR));
$logger->attach(new Stdout(LogLevel::WARN));
$logger->attach(new Stderr(LogLevel::INFO));
$logger->apply();
You can put these elements to PHPUnit's configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php" colors="true">
...
<php>
<env name="PACT_LOG" value="./log/pact.txt"/>
<env name="PACT_LOGLEVEL" value="DEBUG"/>
</php>
<extensions>
<bootstrap class="PhpPact\Log\PHPUnit\PactLoggingExtension"/>
</extensions>
</phpunit>
Consumer:
use PhpPact\Standalone\MockService\MockServerConfig;
$config = new VerifierConfig();
$config->setLogLevel('DEBUG');
Provider:
use PhpPact\Standalone\ProviderVerifier\Model\VerifierConfig;
$config = new VerifierConfig();
$config->setLogLevel('DEBUG');
How can I help you explore Laravel packages today?