### Start Docker Containers with Docker Compose Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/docker_app/HOWTO.md This command starts the Docker containers for the development environment in detached mode. Ensure you are in the 'docker_app' directory. Linux users might need 'sudo'. ```bash cd docker_app docker-compose up -d ``` -------------------------------- ### Install PHP Encryption Library using Composer Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/Defuse/docs/InstallingAndVerifying.md This command installs the 'defuse/php-encryption' library into your composer-enabled project. Composer handles dependency management, but doesn't inherently verify the authenticity of the downloaded code. ```sh composer require defuse/php-encryption ``` -------------------------------- ### Guzzle 5 Event-Based Middleware Example Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md Demonstrates how to use the event system in Guzzle 5 to listen for the 'before' event and modify a request by setting a header. This approach relied on mutability. ```php use GuzzleHttp\Event\BeforeEvent; $client = new GuzzleHttp\Client(); // Get the emitter and listen to the before event. $client->getEmitter()->on('before', function (BeforeEvent $e) { // Guzzle v5 events relied on mutation $e->getRequest()->setHeader('X-Foo', 'Bar'); }); ``` -------------------------------- ### Install PHPMailer using Composer Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/PHPMailer/README.md This snippet shows how to add PHPMailer as a dependency to your project using Composer. Composer is the recommended installation method for managing PHP packages and their dependencies. ```json "phpmailer/phpmailer": "^7.0.0" ``` -------------------------------- ### Install Guzzle using Composer (Bash) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/README.md Provides the command to install the Guzzle HTTP client library using Composer, the dependency manager for PHP. This is the recommended method for adding Guzzle to a PHP project. ```bash composer require guzzlehttp/guzzle ``` -------------------------------- ### Install GuzzleHttp/psr7 via Composer Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/Psr7/README.md This command installs the guzzlehttp/psr7 package using Composer, the dependency manager for PHP. Ensure Composer is installed and accessible in your environment. ```shell composer require guzzlehttp/psr7 ``` -------------------------------- ### Require PHPMailer using Composer CLI Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/PHPMailer/README.md This command demonstrates how to install PHPMailer directly using the Composer command-line interface. It adds the package to your project and handles autoloading. ```sh composer require phpmailer/phpmailer ``` -------------------------------- ### Guzzle Prepare Body Middleware Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md The `GuzzleHttp\Subscriber\Prepare` functionality is now provided by `GuzzleHttp\PrepareBodyMiddleware`. This middleware is responsible for preparing the request body, especially for streaming uploads. The example shows its inclusion in the handler stack. ```php use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; use GuzzleHttp\PrepareBodyMiddleware; $stack = HandlerStack::create(); $stack->push(Middleware::prepareBody()); // Or use PrepareBodyMiddleware directly if needed $client = new Client(['handler' => $stack]); ``` -------------------------------- ### Send Email with PHPMailer in PHP Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/PHPMailer/README.md This snippet demonstrates how to configure and send an email using the PHPMailer library in PHP. It covers setting up SMTP server details, recipients, attachments, and HTML content. Ensure PHPMailer and its autoloader are installed via Composer. ```php SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mail->isSMTP(); //Send using SMTP $mail->Host = 'smtp.example.com'; //Set the SMTP server to send through $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Username = 'user@example.com'; //SMTP username $mail->Password = 'secret'; //SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` //Recipients $mail->setFrom('from@example.com', 'Mailer'); $mail->addAddress('joe@example.net', 'Joe User'); //Add a recipient $mail->addAddress('ellen@example.com'); //Name is optional $mail->addReplyTo('info@example.com', 'Information'); $mail->addCC('cc@example.com'); $mail->addBCC('bcc@example.com'); //Attachments $mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name //Content $mail->isHTML(true); //Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body in bold!'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } ``` -------------------------------- ### Configuring Redirects in Guzzle Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md This example shows the evolution of redirect configuration in Guzzle. The 4.0 version replaces the `configureRedirects()` method with the `allow_redirects` request option, allowing for both standard and strict redirects with custom limits. ```php // Standard redirects with a default of a max of 5 redirects $request = $client->createRequest('GET', '/', ['allow_redirects' => true]); // Strict redirects with a custom number of redirects $request = $client->createRequest('GET', '/', [ 'allow_redirects' => ['max' => 5, 'strict' => true] ]); ``` -------------------------------- ### View Docker Compose Logs Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/docker_app/HOWTO.md These commands display the logs for specific services managed by Docker Compose. 'www' typically refers to the web server logs, and 'db' refers to the database logs. ```bash docker-compose logs www ``` ```bash docker-compose logs db ``` -------------------------------- ### Install Email-Parse using Composer Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/Email/README.md This snippet shows how to add the Email-Parse library to your project's dependencies by including it in the 'require' section of your composer.json file. ```json "require": { ... "mmucklo/email-parse": "*" } ``` -------------------------------- ### Connect to Database using Docker Compose CLI Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/docker_app/HOWTO.md This command allows you to connect to the 'mrbs' database using the MySQL command-line client within the Docker environment. It specifies the username and password for authentication. ```bash docker-compose db mysql -u mrbs -pmrbs mrbs ``` -------------------------------- ### Make Synchronous and Asynchronous HTTP Requests with Guzzle (PHP) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/README.md Demonstrates how to use Guzzle to send both synchronous and asynchronous HTTP requests. It shows how to instantiate the client, make a GET request, retrieve status code, headers, and body. It also illustrates sending an asynchronous request and waiting for its completion. ```php $client = new \GuzzleHttp\Client(); $response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle'); echo $response->getStatusCode(); // 200 echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8' echo $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}' // Send an asynchronous request. $request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org'); $promise = $client->sendAsync($request)->then(function ($response) { echo 'I completed! ' . $response->getBody(); }); $promise->wait(); ``` -------------------------------- ### Guzzle 6 Functional Middleware Example Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md Illustrates the Guzzle 6 approach to modifying requests using functional middleware. It shows how to create a handler stack and push a `mapRequest` middleware to add a header to the request, returning a new request object. ```php use GuzzleHttp\Middleware; // Create a handler stack that has all of the default middlewares attached $handler = GuzzleHttp\HandlerStack::create(); // Push the handler onto the handler stack $handler->push(Middleware::mapRequest(function (RequestInterface $request) { // Notice that we have to return a request object return $request->withHeader('X-Foo', 'Bar'); })); // Inject the handler into the client $client = new GuzzleHttp\Client(['handler' => $handler]); ``` -------------------------------- ### Guzzle Middleware for Cookie Handling Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md The `GuzzleHttp\Subscriber\Cookie` functionality is now provided by `GuzzleHttp\Middleware::cookies`. This allows for cookie management within the new middleware system. The example demonstrates how to use the `cookies` middleware when creating a client. ```php use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; $stack = HandlerStack::create(); $stack->push(Middleware::cookies()); $client = new Client(['handler' => $stack]); ``` -------------------------------- ### Unlock User Key on Login (PHP) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/Defuse/docs/Tutorial.md This code demonstrates how to retrieve a password-protected key from a user's account record upon successful login. It then uses the user's password to unlock the key, obtaining a usable `Key` object. This key is then encoded and saved securely, for example, in a cookie, for subsequent use during the user's session. ```php unlockKey($password); $user_key_encoded = $user_key->saveToAsciiSafeString(); // ... save $user_key_encoded in a cookie ``` -------------------------------- ### Configure SAML Authentication in MRBS Source: https://context7.com/meeting-room-booking-system/mrbs-code/llms.txt Sets up SAML authentication for MRBS using SimpleSAMLphp. This requires specifying the path to the SimpleSAMLphp installation, the authentication source, and mapping SAML attributes to MRBS username and email fields. Administrator group membership can also be configured. ```php // SAML authentication with SimpleSAMLphp $auth['type'] = 'saml'; $auth['session'] = 'saml'; $auth['saml']['ssp_path'] = '/opt/simplesamlphp'; $auth['saml']['authsource'] = 'default-sp'; $auth['saml']['attr']['username'] = 'sAMAccountName'; $auth['saml']['attr']['mail'] = 'mail'; $auth['saml']['admin']['memberOf'] = ['CN=MRBS Admins,DC=example,DC=com']; ``` -------------------------------- ### Parse Email Addresses using Email-Parse (PHP) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/Email/README.md This PHP code demonstrates how to use the Email-Parse library to parse a string containing multiple email addresses. It utilizes the getInstance() method to get a parser instance and then calls the parse() method with the email string. ```php use Email\Parse; $result = Parse::getInstance()->parse("a@aaa.com b@bbb.com"); ``` -------------------------------- ### Key Class - Instance Methods Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/Defuse/docs/classes/Key.md Documentation for instance methods of the Key class. ```APIDOC ## saveToAsciiSafeString() ### Description Saves the encryption key to a string of printable ASCII characters, which can be loaded again into a `Key` instance using `Key::loadFromAsciiSafeString()`. ### Method `instance` ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response (200) - **string** - A string of printable ASCII characters representing this `Key` instance. #### Response Example ``` "a1b2c3d4e5f67890..." ``` ### Exceptions - `Defuse\Crypto\Exception\EnvironmentIsBrokenException`: Thrown if the platform cannot safely perform encryption or if runtime tests detect a bug. ``` -------------------------------- ### Initializing Guzzle Client with Options (PHP) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md Explains how to initialize the Guzzle client in version 4.0. The constructor now accepts an associative array for configuration, including base URLs, default options, adapters, and message factories. ```php $client = new GuzzleHttp\Client([ 'base_url' => 'http://example.com', 'defaults' => [ 'headers' => ['Foo' => 'bar'] ] ]); ``` -------------------------------- ### Create User Account with Password-Protected Key (PHP) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/Defuse/docs/Tutorial.md This snippet shows how to create a new user account and generate a random key protected by the user's login password. The protected key is then saved in an ASCII-safe string format to be stored with the user's account record. This is the first step in securing user data using password-based encryption. ```php saveToAsciiSafeString(); // ... save $protected_key_encoded into the user's account record } ``` -------------------------------- ### Load Encryption Key from Configuration using PHP Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/Defuse/docs/Tutorial.md This PHP function illustrates how to load an encryption key from a secure configuration file. It reads the key from a specified path and uses `Key::loadFromAsciiSafeString()` to create a usable Key object. ```php push(Middleware::redirect()); // Or use RedirectMiddleware directly if needed $client = new Client(['handler' => $stack]); ``` -------------------------------- ### GET /report.php Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/help_report.html Generates reports based on specified criteria. This endpoint can be accessed via a web browser by constructing a URL with query parameters or used with command-line tools like wget. ```APIDOC ## GET /report.php ### Description Generates reports based on specified criteria. This endpoint can be accessed via a web browser by constructing a URL with query parameters or used with command-line tools like wget. ### Method GET ### Endpoint /report.php ### Query Parameters - **phase** (integer) - Required - Must be set to '2' to indicate the second phase of report production. - **output** (integer) - Required - Specifies the output mode. Example: '1'. - **output_format** (integer) - Optional - Specifies the desired output format. Example: '2' for CSV. Defaults may vary when accessed from a browser. - **from_date** (string) - Optional - The start date for the report, in 'YYYY-MM-DD' format. - **to_date** (string) - Optional - The end date for the report, in 'YYYY-MM-DD' format. - **sumby** (string) - Optional - Criteria for summarizing the report. Example: 'c'. ### Request Example (Browser Simulation) ``` http://localhost/mrbs/report.php?phase=2&output=1&output_format=2&from_date=2019-01-01&to_date=2020-01-01&sumby=c ``` ### Request Example (wget) ```bash wget -O myreport.csv "http://localhost/mrbs/report.php?phase=2&output=1&output_format=2&sumby=c" ``` ### Response #### Success Response (200) - **report_data** (string) - The generated report content, format depends on `output_format`. #### Response Example (CSV) ```csv column1,column2,column3 value1,value2,value3 ``` ``` -------------------------------- ### Simulate MRBS Report in Browser Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/help_report.html Simulates MRBS CLI report generation by passing parameters as a query string in a browser URL. Requires `phase=2` to indicate the second phase of report production. Additional parameters like `output_format` are needed for browser-based execution. ```url http://localhost/mrbs/report.php?phase=2&output=1&output_format=2&from_date=2019-01-01&to_date=2020-01-01&sumby=c ``` -------------------------------- ### Guzzle Middleware for Request History Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md The `GuzzleHttp\Subscriber\History` functionality is now provided by `GuzzleHttp\Middleware::history`. This middleware allows you to record the history of requests and responses made by the client. The example shows how to initialize the history middleware. ```php use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; $history = []; $stack = HandlerStack::create(); $stack->push(Middleware::history($history)); $client = new Client(['handler' => $stack]); // After making requests, $history will contain the transaction details. ``` -------------------------------- ### Generate Encryption Key using PHP-Encryption Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/Defuse/docs/Tutorial.md This snippet demonstrates how to generate a random encryption key using the `generate-defuse-key` script provided by the `defuse/php-encryption` library. The generated key is printed to standard output and should be saved securely. ```shell composer require defuse/php-encryption vendor/bin/generate-defuse-key ``` -------------------------------- ### Simulate MRBS Report with wget Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/help_report.html Uses the `wget` command-line utility to download an MRBS report. Parameters are passed in the URL, and ampersands (`&`) must be escaped with a backslash (`\`). The `-O` flag specifies the output file name. ```bash wget -O myreport.csv http://localhost/mrbs/report.php?phase=2\&output=1\&output_format=2\&sumby=c ``` -------------------------------- ### Guzzle Middleware for HTTP Error Handling Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md The `GuzzleHttp\Subscriber\HttpError` functionality is now provided by `GuzzleHttp\Middleware::httpError`. This middleware intercepts HTTP errors and can be configured to throw exceptions for non-2xx responses. The example shows its integration into a handler stack. ```php use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; $stack = HandlerStack::create(); $stack->push(Middleware::httpError()); $client = new Client(['handler' => $stack]); ``` -------------------------------- ### Check URI Type: Relative Path Reference Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/Psr7/README.md Determines if a Psr\Http\Message\UriInterface is a relative-path reference. These references do not begin with a slash and are interpreted relative to the directory of the base URI. Example: 'subpath'. ```PHP use Psr\Http\Message\UriInterface; use GuzzleHttp\Psr7\Uri; // Assuming $uri is an instance of UriInterface $isRelativePath = Uri::isRelativePathReference($uri); ``` -------------------------------- ### Convert HTTP Message to String with GuzzleHttpPsr7Message::toString (PHP) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/Psr7/README.md Demonstrates the usage of the static method GuzzleHttp\Psr7\Message::toString to get a string representation of an HTTP message. This is useful for debugging or logging. ```php $request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com'); echo GuzzleHttp\Psr7\Message::toString($request); ``` -------------------------------- ### Implement Custom Stream Decorator with GuzzleHttpPsr7StreamDecoratorTrait (PHP) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/Psr7/README.md Shows how to create a custom stream decorator by using the GuzzleHttp\Psr7\StreamDecoratorTrait. This example implements a stream that executes a callback when the end-of-file is reached during a read operation. ```php use Psr\Http\Message\StreamInterface; use GuzzleHttp\Psr7\StreamDecoratorTrait; class EofCallbackStream implements StreamInterface { use StreamDecoratorTrait; private $callback; private $stream; public function __construct(StreamInterface $stream, callable $cb) { $this->stream = $stream; $this->callback = $cb; } public function read($length) { $result = $this->stream->read($length); // Invoke the callback when EOF is hit. if ($this->eof()) { ($this->callback)(); } return $result; } } use GuzzleHttpPsr7; $original = Psr7Utils::streamFor('foo'); $eofStream = new EofCallbackStream($original, function () { echo 'EOF!'; }); $eofStream->read(2); $eofStream->read(1); // echoes "EOF!" $eofStream->seek(0); $eofStream->read(3); // echoes "EOF!" ``` -------------------------------- ### Configuring SSL Verification in Guzzle Client (PHP) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md Illustrates how to set SSL verification options for the Guzzle client. The `setSslVerification()` method has been removed in favor of default request options. ```php $client->setConfig('defaults/verify', true); ``` -------------------------------- ### Update Guzzle Configuration Handling: Inspector to Collection (PHP) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md This snippet demonstrates the refactoring of a Guzzle service client's factory method. It shows how to replace the deprecated `Guzzle\Service\Inspector::fromConfig` with the current `Guzzle\Common\Collection::fromConfig` for managing client configuration. This change ensures compatibility with newer Guzzle versions and utilizes the recommended collection class for configuration data. ```php use Guzzle\Service\Client; use Guzzle\Common\Collection; use Guzzle\Service\Description\ServiceDescription; class YourClient extends Client { public static function factory($config = array()) { $default = array(); $required = array('base_url', 'username', 'api_key'); $config = Collection::fromConfig($config, $default, $required); $client = new self( $config->get('base_url'), $config->get('username'), $config->get('api_key') ); $client->setConfig($config); $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json')); return $client; } } ``` -------------------------------- ### URI Handling with Guzzle 6 Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md Guzzle 6 now uses `Psr\Http\Message\UriInterface`, with `GuzzleHttp\Psr7\Uri` as the implementation. The `GuzzleHttp\Url` class has been removed. This change aligns Guzzle with the PSR-7 standard for URI representation. The example shows creating a PSR-7 compliant URI object. ```php use GuzzleHttp\Psr7\Uri; $uri = new Uri('http://example.com/path?query=string'); echo $uri->getScheme(); // http echo $uri->getHost(); // example.com echo $uri->getPath(); // /path echo $uri->getQuery(); // query=string ``` -------------------------------- ### Renamed Client Configuration Method in Guzzle 6 Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md The `GuzzleHttp\ClientInterface::getDefaultOption` method has been renamed to `GuzzleHttp\ClientInterface::getConfig`. This change reflects a more standard naming convention for accessing client configuration settings. The example shows how to retrieve configuration using the new method. ```php use GuzzleHttp\Client; $client = new Client(); // Before (Guzzle 5): // $defaultTimeout = $client->getDefaultOption('timeout'); // After (Guzzle 6): $configValue = $client->getConfig('timeout'); ``` -------------------------------- ### Guzzle Logging Plugin: Namespace and Adapter Changes (PHP) Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md Illustrates the migration of Guzzle's logging functionality. The LogPlugin namespace has changed, and the ClosureLogAdapter now uses a format string instead of a verbosity level. MessageFormatter is introduced for defining log formats. ```php use Guzzle\Common\Log\ClosureLogAdapter; use Guzzle\Http\Plugin\LogPlugin; /** @var \Guzzle\Http\Client */ $client; // $verbosity is an integer indicating desired message verbosity level $client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $verbosity = LogPlugin::LOG_VERBOSE)); ``` ```php use Guzzle\Log\ClosureLogAdapter; use Guzzle\Log\MessageFormatter; use Guzzle\Plugin\Log\LogPlugin; /** @var \Guzzle\Http\Client */ $client; // $format is a string indicating desired message format -- @see MessageFormatter $client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $format = MessageFormatter::DEBUG_FORMAT)); ``` -------------------------------- ### Guzzle Mock Handler for Testing Source: https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/GuzzleHttp/UPGRADING.md The `GuzzleHttp\Subscriber\Mock` functionality is now replaced by `GuzzleHttp\Handler\MockHandler`. This handler is used for mocking HTTP responses during testing, allowing you to simulate various server responses without making actual network requests. The example shows how to configure the MockHandler. ```php use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\Psr7\Response; $mock = new MockHandler([ new Response(200, ['X-Foo' => 'Bar']), new Response(404, ['X-Foo' => 'Baz']) ]); $stack = HandlerStack::create($mock); $client = new Client(['handler' => $stack]); $response1 = $client->request('GET', '/'); // Returns the first mock response $response2 = $client->request('GET', '/'); // Returns the second mock response ```