### Install composer/pcre Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/composer/pcre/README.md Install the latest version of the library using Composer. ```bash $ composer require composer/pcre ``` -------------------------------- ### Install PHP Complex Library Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Install the library using Composer. ```shell composer require markbaker/complex:^1.0 ``` -------------------------------- ### Install PHP Complex Functions Library Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Install the separate library for procedural function calls. ```shell composer require markbaker/complex-functions:^3.0 ``` -------------------------------- ### Install Symfony Polyfill for Mbstring Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/index.rst Install this package if your installation is missing the mbstring extension and composer install fails. ```sh composer require symfony/polyfill-mbstring ``` -------------------------------- ### Install PHPMatrix Functions using Composer Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Install the PHPMatrixFunctions library, recommended for procedural calls from version 3.0 onwards. ```shell composer require markbaker/matrix-functions:^1.0 ``` -------------------------------- ### Install PHPMatrix using Composer Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Install the PHPMatrix library version 3.0 or higher using Composer. ```shell composer require markbaker/matrix:^3.0 ``` -------------------------------- ### Install PSR7 and GuzzleHTTP Dependencies Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/index.rst Install these dependencies if you need to use addFileFromPsr7Stream or a stream as an output stream. ```sh composer require psr/http-message guzzlehttp/psr7 ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/phpoffice/phpspreadsheet/CONTRIBUTING.md Run this command within your PhpSpreadsheet clone to install necessary development dependencies. ```bash composer install ``` -------------------------------- ### Basic ZipStream PHP Usage Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/index.rst This example demonstrates how to create a zip archive, add files from different sources, and finish the stream. Ensure dependencies are autoloaded. ```php // Autoload the dependencies require 'vendor/autoload.php'; // create a new zipstream object $zip = new ZipStream\ZipStream( outputName: 'example.zip', // enable output of HTTP headers sendHttpHeaders: true, ); // create a file named 'hello.txt' $zip->addFile( fileName: 'hello.txt', data: 'This is the contents of hello.txt', ); // add a file named 'some_image.jpg' from a local file 'path/to/image.jpg' $zip->addFileFromPath( fileName: 'some_image.jpg', path: 'path/to/image.jpg', ); // add a file named 'goodbye.txt' from an open stream resource $filePointer = tmpfile(); fwrite($filePointer, 'The quick brown fox jumped over the lazy dog.'); rewind($filePointer); $zip->addFileFromStream( fileName: 'goodbye.txt', stream: $filePointer, ); fclose($filePointer); // add a file named 'streamfile.txt' from the body of a `guzzle` response // Setup with `psr/http-message` & `guzzlehttp/psr7` dependencies required. $zip->addFileFromPsr7Stream( fileName: 'streamfile.txt', stream: $response->getBody(), ); // finish the zip stream $zip->finish(); ``` -------------------------------- ### Install ZipStream PHP with Composer Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/index.rst Use Composer to add the zipstream-php package to your project dependencies. ```sh composer require maennchen/zipstream-php ``` -------------------------------- ### Prepend to HTTP Message Body (Stream Behavior) Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Usage.md Illustrates the behavior of prepending to a stream body. Due to stream mechanics, prepending requires seeking to the beginning and writing, which overwrites existing content from the start. ```php // assuming our response is initially empty $body = $repsonse->getBody(); // writing the string "abcd" $body->write('abcd'); // seeking to start of stream $body->seek(0); // writing 'ef' $body->write('ef'); // at this point the stream contains "efcd" ``` -------------------------------- ### PREG_UNMATCHED_AS_NULL Behavior Example Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/composer/pcre/README.md Demonstrates the difference in match results when using PREG_UNMATCHED_AS_NULL compared to no flag. This is useful for understanding how unmatched groups are represented. ```php preg_match('/(a)(b)*(c)(d)*/', 'ac', $matches, $flags); ``` -------------------------------- ### Get and Replace HTTP Message Body Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Usage.md Demonstrates how to get the body stream from an HTTP response, perform operations on it, and then replace it. This is useful for repeated body operations. ```php $body = $response->getBody(); // operations on body, eg. read, write, seek // ... // replacing the old body $response->withBody($body); // this last statement is optional as we working with objects // in this case the "new" body is same with the "old" one // the $body variable has the same value as the one in $request, only the reference is passed ``` -------------------------------- ### Get Header Array Value Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Usage.md Retrieves a header's value as an array of strings. This applies to both request and response headers. ```php $request->getHeader('Content-Type'); // will return: ["text/html", "charset=UTF-8"] ``` ```php $response->getHeader('My-Custom-Header'); // will return: ["My Custom Message", "The second message"] ``` -------------------------------- ### Get Header Line Value Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Usage.md Retrieves a header's value as a comma-separated string. This applies to both request and response headers. ```php $request->getHeaderLine('Content-Type'); // will return: "text/html; charset=UTF-8" ``` ```php $response->getHeaderLine('My-Custom-Header'); // will return: "My Custom Message; The second message" ``` -------------------------------- ### Perform matrix multiplication using method chaining Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Multiply two matrices using the multiply method and chain it with toArray to get the result as an array. Matrix objects are immutable, returning a new object. ```php $matrix1 = new Matrix\Matrix([ [2, 7, 6], [9, 5, 1], [4, 3, 8], ]); $matrix2 = new Matrix\Matrix([ [1, 2, 3], [4, 5, 6], [7, 8, 9], ]); var_dump($matrix1->multiply($matrix2)->toArray()); ``` -------------------------------- ### Get Body Contents with Rewind Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Usage.md Retrieves the entire content of an HTTP message body as a string. It's crucial to rewind the stream before reading to ensure all content is captured. ```php $body = $response->getBody(); $body->rewind(); // or $body->seek(0); $bodyText = $body->getContents(); ``` -------------------------------- ### Configuring ZipStream with All Available Options Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/Options.rst Demonstrates how to initialize ZipStream with a comprehensive set of options, including output stream definition, deflate level, comments, HTTP header settings, content disposition, output name, content type, header callback, zero header enabling, Zip64 extension, and buffer flushing. ```php use ZipStream\ZipStream; require_once 'vendor/autoload.php'; $zip = new ZipStream( // Define output stream // (argument is either a resource or implementing // `Psr\Http\Message\StreamInterface`) // // Setup with `psr/http-message` & `guzzlehttp/psr7` dependencies // required when using `Psr\Http\Message\StreamInterface`. // // Can also use CallbackStreamWrapper for custom output handling: // outputStream: CallbackStreamWrapper::open(function($data) { /* handle data */ }), outputStream: $filePointer, // Set the deflate level (default is 6; use -1 to disable it) defaultDeflateLevel: 6, // Add a comment to the zip file comment: 'This is a comment.', // Send http headers (default is true) sendHttpHeaders: false, // HTTP Content-Disposition. // Defaults to 'attachment', where FILENAME is the specified filename. // Note that this does nothing if you are not sending HTTP headers. contentDisposition: 'attachment', // Output Name for HTTP Content-Disposition // Defaults to no name outputName: "example.zip", // HTTP Content-Type. // Defaults to 'application/x-zip'. // Note that this does nothing if you are not sending HTTP headers. contentType: 'application/x-zip', // Set the function called for setting headers. // Default is the `header()` of PHP httpHeaderCallback: header(...), // Enable streaming files with single read where general purpose bit 3 // indicates local file header contain zero values in crc and size // fields, these appear only after file contents in data descriptor // block. // Set to true if your input stream is remote // (used with addFileFromStream()). // Default is false. defaultEnableZeroHeader: false, // Enable zip64 extension, allowing very large archives // (> 4Gb or file count > 64k) // Default is true enableZip64: true, // Flush output buffer after every write // Default is false flushOutput: true, ); ``` -------------------------------- ### Mathematical Operations (Instance Methods) Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Shows how to perform mathematical operations like addition using instance methods on a Complex object. ```APIDOC ## Mathematical Operations (Instance Methods) ### Description Perform mathematical operations directly on a Complex object by calling its methods. These methods are immutable, meaning they return a new Complex object with the result and leave the original object unchanged. This allows for method chaining. ### Method `add(value)` `subtract(value)` `multiply(value)` `divide(value)` `divideBy(value)` `divideInto(value)` `theta()` `rho()` `conjugate()` `negative()` `inverse()` `cos()` `acos()` `cosh()` `acosh()` `sin()` `asin()` `sinh()` `asinh()` `sec()` `asec()` `sech()` `asech()` `csc()` `acsc()` `csch()` `acsch()` `tan()` `atan()` `tanh()` `atanh()` `cot()` `acot()` `coth()` `acoth()` `sqrt()` `exp()` `ln()` `log10()` `log2()` `pow(real)` ### Parameters #### value - **value** (Complex|array|string) - The value to perform the operation with. Can be a Complex object, an array that can be parsed into a Complex object, or a string representation of a complex number. #### real - **real** (float) - The real number to raise the complex number to the power of. ### Request Example ```php $complexString1 = '1.23-4.56i'; $complexString2 = '2.34+5.67i'; $complexObject = new Complex\Complex($complexString1); echo $complexObject->add($complexString2); // Chaining example echo $complexObject->add($complexString2)->subtract('1+1i'); ``` ### Response Returns a new Complex object with the result of the operation. ``` -------------------------------- ### Basic ZipStream Usage Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/README.md Create a zip stream, add files by content or from a path, and finish the stream. Ensure dependencies are autoloaded. ```php // Autoload the dependencies require 'vendor/autoload.php'; // create a new zipstream object $zip = new ZipStream\ZipStream( outputName: 'example.zip', // enable output of HTTP headers sendHttpHeaders: true, ); // create a file named 'hello.txt' $zip->addFile( fileName: 'hello.txt', data: 'This is the contents of hello.txt', ); // add a file named 'some_image.jpg' from a local file 'path/to/image.jpg' $zip->addFileFromPath( fileName: 'some_image.jpg', path: 'path/to/image.jpg', ); // finish the zip stream $zip->finish(); ``` -------------------------------- ### Mathematical Operations (Static Methods) Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Demonstrates how to perform mathematical operations using static methods from the Operations class. ```APIDOC ## Mathematical Operations (Static Methods) ### Description Perform mathematical operations using static methods provided by the `Complex\Operations` class. This approach is useful for performing operations without needing an existing Complex object instance. ### Method `Complex\Operations::add(value1, value2, ...)` `Complex\Operations::subtract(value1, value2, ...)` `Complex\Operations::multiply(value1, value2, ...)` `Complex\Operations::divide(value1, value2, ...)` `Complex\Operations::divideBy(value1, value2, ...)` `Complex\Operations::divideInto(value1, value2, ...)` `Complex\Operations::theta(value)` `Complex\Operations::rho(value)` `Complex\Operations::conjugate(value)` `Complex\Operations::negative(value)` `Complex\Operations::inverse(value)` `Complex\Operations::cos(value)` `Complex\Operations::acos(value)` `Complex\Operations::cosh(value)` `Complex\Operations::acosh(value)` `Complex\Operations::sin(value)` `Complex\Operations::asin(value)` `Complex\Operations::sinh(value)` `Complex\Operations::asinh(value)` `Complex\Operations::sec(value)` `Complex\Operations::asec(value)` `Complex\Operations::sech(value)` `Complex\Operations::asech(value)` `Complex\Operations::csc(value)` `Complex\Operations::acsc(value)` `Complex\Operations::csch(value)` `Complex\Operations::acsch(value)` `Complex\Operations::tan(value)` `Complex\Operations::atan(value)` `Complex\Operations::tanh(value)` `Complex\Operations::atanh(value)` `Complex\Operations::cot(value)` `Complex\Operations::acot(value)` `Complex\Operations::coth(value)` `Complex\Operations::acoth(value)` `Complex\Operations::sqrt(value)` `Complex\Operations::exp(value)` `Complex\Operations::ln(value)` `Complex\Operations::log10(value)` `Complex\Operations::log2(value)` `Complex\Operations::pow(value, real)` ### Parameters #### value - **value** (Complex|array|string) - The value to perform the operation with. Can be a Complex object, an array that can be parsed into a Complex object, or a string representation of a complex number. #### value1, value2, ... - **value1, value2, ...** (Complex|array|string) - Multiple values to perform the operation against. Accepts any number of arguments. #### real - **real** (float) - The real number to raise the complex number to the power of. ### Request Example ```php $complexString1 = '1.23-4.56i'; $complexString2 = '2.34+5.67i'; echo Complex\Operations::add($complexString1, $complexString2); // Performing operation on multiple values echo Complex\Operations::add($complexString1, $complexString2, '3+4i'); ``` ### Response Returns a Complex object with the result of the operation. ``` -------------------------------- ### Adding Content-Length Header with SIMULATION_STRICT Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/ContentLength.rst This snippet demonstrates how to initialize ZipStream in SIMULATION_STRICT mode to calculate the archive size and set the Content-Length header before streaming. It shows adding files directly and using callbacks with exact sizes for deferred resource opening. ```php use ZipStream\OperationMode; use ZipStream\ZipStream; $zip = new ZipStream( operationMode: OperationMode::SIMULATE_STRICT, // or SIMULATE_LAX defaultEnableZeroHeader: false, sendHttpHeaders: true, outputStream: $stream, ); // Normally add files $zip->addFile('sample.txt', 'Sample String Data'); // Use addFileFromCallback and exactSize if you want to defer opening of // the file resource $zip->addFileFromCallback( 'sample.txt', exactSize: 18, callback: function () { return fopen('...'); } ); // Read resulting file size $size = $zip->finish(); // Tell it to the browser header('Content-Length: '. $size); // Execute the Simulation and stream the actual zip to the client $zip->executeSimulation(); ``` -------------------------------- ### Basic preg_* function replacements Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/composer/pcre/README.md Demonstrates the equivalent usage of standard preg_* functions with the Composer\Pcre\Preg class. ```php use Composer\Pcre\Preg; if (Preg::match('{fo+}', $string, $matches)) { ... } if (Preg::matchWithOffsets('{fo+}', $string, $matches)) { ... } if (Preg::matchAll('{fo+}', $string, $matches)) { ... } $newString = Preg::replace('{fo+}', 'bar', $string); $newString = Preg::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string); $newString = Preg::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string); $filtered = Preg::grep('{[a-z]}', $elements); $array = Preg::split('{[a-z]+}', $string); ``` -------------------------------- ### Saving ZipStream Output to Flysystem Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/FlySystem.rst This snippet demonstrates how to create a zip archive in memory and then upload it using a Flysystem local adapter. Ensure the stream is opened in 'w+' mode for read/write access and is closed after the upload. ```php // Open Stream only once for read and write since it's a memory stream and // the content is lost when closing the stream / opening another one $tempStream = fopen('php://memory', 'w+'); // Create Zip Archive $zipStream = new ZipStream( outputStream: $tempStream, outputName: 'test.zip', ); $zipStream->addFile('test.txt', 'text'); $zipStream->finish(); // Store File // (see Flysystem documentation, and all its framework integration) // Can be any adapter (AWS, Google, Ftp, etc.) $adapter = new Local(__DIR__.'/path/to/folder'); $filesystem = new Filesystem($adapter); $filesystem->writeStream('test.zip', $tempStream) // Close Stream fclose($tempStream); ``` -------------------------------- ### Identify Coding Style Issues Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/phpoffice/phpspreadsheet/CONTRIBUTING.md Execute this command to check your code against the project's coding style standards. ```bash composer style ``` -------------------------------- ### Create a new Matrix object Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Instantiate a new Matrix object by passing a 2D array representing the grid to the constructor. ```php $grid = [ [16, 3, 2, 13], [ 5, 10, 11, 8], [ 9, 6, 7, 12], [ 4, 15, 14, 1], ]; $matrix = new Matrix\Matrix($grid); ``` -------------------------------- ### Create Annotated Git Tag Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/phpoffice/phpspreadsheet/CONTRIBUTING.md Steps for creating an annotated Git tag for a new release, including setting the tag subject and body. ```bash git tag -a 1.2.3 ``` -------------------------------- ### Stream ZIP with Callback for Progress Tracking Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/StreamOutput.rst Utilize a callback function with ZipStream to track the total bytes transferred, enabling progress reporting to a tracking system. ```php // Example 2: Progress tracking $totalBytes = 0; $zip = new ZipStream( outputStream: CallbackStreamWrapper::open(function (string $data) use (&$totalBytes) { $totalBytes += strlen($data); reportProgress($totalBytes); // Report progress to your tracking system // Your actual output handling echo $data; }), sendHttpHeaders: false, ); $zip->addFile('large_file.txt', str_repeat('A', 10000)); $zip->finish(); ``` -------------------------------- ### Test Version Compatibility Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/phpoffice/phpspreadsheet/CONTRIBUTING.md Use this Composer command to test code compatibility across supported PHP versions. ```bash composer versions ``` -------------------------------- ### Create Image Sitemap Source: https://github.com/sterc/seosuite/blob/master/readme.md Generate a sitemap specifically for images by setting the 'type' parameter to 'images'. ```MODX [[!SeoSuiteSitemap? &type=`images`]] ``` -------------------------------- ### Matrix Decomposition using QR Class Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Perform QR decomposition on a matrix by instantiating the QR class with a Matrix object. Access the Q and R components using their respective getter methods. ```php $grid = [ [1, 2], [3, 4], ]; $matrix = new Matrix\Matrix($grid); $decomposition = new Matrix\Decomposition\QR($matrix); $Q = $decomposition->getQ(); $R = $decomposition->getR(); ``` -------------------------------- ### Complex Number Creation Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Demonstrates how to create new Complex objects using the constructor with real, imaginary, and suffix parts, or as an array of values, or as a string. ```APIDOC ## Complex Number Creation ### Description Creates a new complex number object. The constructor can accept the real, imaginary, and suffix parts as individual arguments, as an array of these values, or as a string representation of the complex number. ### Method `__construct(real, imaginary, suffix)` or `__construct([real, imaginary, suffix])` or `__construct(string)` ### Parameters #### Arguments - **real** (float) - The real part of the complex number. - **imaginary** (float) - The imaginary part of the complex number. - **suffix** (string) - The suffix for the imaginary part (e.g., 'i'). #### Array Arguments - **arguments** (array) - An array containing the real, imaginary, and suffix parts in that order. #### String Argument - **complexString** (string) - A string representing the complex number (e.g., '1.23-4.56i'). ### Request Example ```php // Using individual arguments $complexObject1 = new Complex\Complex(1.23, -4.56, 'i'); // Using an array of arguments $arguments = [1.23, -4.56, 'i']; $complexObject2 = new Complex\Complex($arguments); // Using a string $complexString = '1.23-4.56i'; $complexObject3 = new Complex\Complex($complexString); ``` ### Response Returns a new Complex object representing the provided complex number. ``` -------------------------------- ### Create an identity matrix using Builder Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Use the Builder class to create an identity matrix of a specified size. ```php $matrix = Matrix\Builder::createIdentityMatrix(3); ``` -------------------------------- ### All SeoSuiteMeta Placeholders Source: https://github.com/sterc/seosuite/blob/master/readme.md This snippet displays all available metadata placeholders when the 'toPlaceholders' option is enabled. These are typically set by a plugin but can be managed manually. ```html [[!+ss_meta.meta_title]] [[!+ss_meta.meta_description]] [[!+ss_meta.robots]] [[!+ss_meta.canonical]] [[!+ss_meta.alternates]] [[!+ss_meta.og_title]] [[!+ss_meta.og_description]] [[!+ss_meta.og_image]] [[!+ss_meta.og_image_alt]] [[!+ss_meta.og_type]] [[!+ss_meta.twitter_site]] [[!+ss_meta.twitter_title]] [[!+ss_meta.twitter_description]] [[!+ss_meta.twitter_image]] [[!+ss_meta.twitter_image_alt]] [[!+ss_meta.twitter_card]] ``` -------------------------------- ### Create a filled matrix using Builder Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Use the Builder class to create a matrix of specified dimensions filled with a set value. ```php $matrix = Matrix\Builder::createFilledMatrix(1, 5, 3); ``` -------------------------------- ### Push Git Tags Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/phpoffice/phpspreadsheet/CONTRIBUTING.md Push all local tags to the remote repository to trigger automated release creation. ```bash git push --tags ``` -------------------------------- ### Create Sitemap Index Source: https://github.com/sterc/seosuite/blob/master/readme.md Generate a sitemap index by specifying the 'index' type. This is useful for organizing multiple child sitemaps. ```MODX [[!SeoSuiteSitemap? &type=`index`]] ``` -------------------------------- ### Matrix Decomposition using Decomposition Factory Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Perform matrix decomposition using the Decomposition factory. Specify the desired decomposition type (e.g., QR) and pass the Matrix object. Access Q and R components. ```php $grid = [ [1, 2], [3, 4], ]; $matrix = new Matrix\Matrix($grid); $decomposition = Matrix\Decomposition\Decomposition::decomposition(Matrix\Decomposition\Decomposition::QR, $matrix); $Q = $decomposition->getQ(); $R = $decomposition->getR(); ``` -------------------------------- ### Create Complex Object from Real, Imaginary, and Suffix Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Instantiate a Complex object using individual real, imaginary, and suffix values. ```php $real = 1.23; $imaginary = -4.56; $suffix = 'i'; $complexObject = new Complex\Complex($real, $imaginary, $suffix); ``` -------------------------------- ### Calling sinh() using Complex\Functions static method Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Shows how to call the sinh() function using the static Functions class. ```php $complexString = '1.23-4.56i'; echo Complex\Functions::sinh($complexString); ``` -------------------------------- ### Calling pow() using Complex\Functions static method Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Illustrates calling the pow() function with a Complex object and an exponent using the static Functions class. ```php $complexString = '1.23-4.56i'; $complexObject = new Complex\Complex($complexString); echo Complex\Functions::pow($complexObject, 2); ``` -------------------------------- ### Varnish VCL Configuration for ZipStream-PHP Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/Varnish.rst Add this VCL code to your Varnish configuration to enable the 'pipe' function for specific file types, preventing random stream closures when serving large zip files. ```vcl sub vcl_recv { # Varnish can’t intercept the discussion anymore # helps for streaming big zips if (req.url ~ "\.(tar|gz|zip|7z|exe)$") { return (pipe); } } # Varnish can’t intercept the discussion anymore # helps for streaming big zips sub vcl_pipe { set bereq.http.connection = "close"; return (pipe); } ``` -------------------------------- ### Stream ZIP to Callback Function (Multiple Destinations) Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/StreamOutput.rst Stream ZIP data to a callback function that can handle multiple output destinations simultaneously, such as echoing to the browser, writing to a file, and logging. ```php use ZipStream\ZipStream; use ZipStream\Stream\CallbackStreamWrapper; // Example 1: Stream to multiple destinations with proper file handling $backupFile = fopen('backup.zip', 'wb'); $logFile = fopen('transfer.log', 'ab'); $zip = new ZipStream( outputStream: CallbackStreamWrapper::open(function (string $data) use ($backupFile, $logFile) { // Send to browser echo $data; // Save to file efficiently fwrite($backupFile, $data); // Log transfer progress fwrite($logFile, "Transferred " . strlen($data) . " bytes\n"); }), sendHttpHeaders: false, ); $zip->addFile('hello.txt', 'Hello World!'); $zip->finish(); // Clean up resources fclose($backupFile); fclose($logFile); ``` -------------------------------- ### Fix Coding Style Issues Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/phpoffice/phpspreadsheet/CONTRIBUTING.md Run this command to automatically fix most coding style issues identified by the linter. ```bash composer fix ``` -------------------------------- ### Calling pow() using Complex object method Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Demonstrates calling the pow() function with an exponent directly on a Complex object instance. ```php $complexString = '1.23-4.56i'; $complexObject = new Complex\Complex($complexString); echo $complexObject->pow(2); ``` -------------------------------- ### Create Default Page Sitemap Source: https://github.com/sterc/seosuite/blob/master/readme.md Use this snippet to generate a default page sitemap. Ensure the MODX resource has an empty template, XML content type, and caching/rich text enabled. ```MODX [[!SeoSuiteSitemap]] ``` -------------------------------- ### Call Matrix Function via Static Method (Matrix Object) Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Call a matrix function using the static method of the Functions class, passing the Matrix object as an argument. Requires instantiation of the Matrix class. ```php $grid = [ [16, 3, 2, 13], [ 5, 10, 11, 8], [ 9, 6, 7, 12], [ 4, 15, 14, 1], ]; $matrix = new Matrix\Matrix($grid); echo Matrix\Functions::trace($matrix); ``` -------------------------------- ### Prepend to Stream Using String Contents Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Usage.md Prepends content to a PSR-7 response body stream by reading its contents into a string, prepending to the string, rewinding the stream, and writing the modified string back. ```php $body = $response->getBody(); $body->rewind(); $contents = $body->getContents(); // efabcd $contents = 'ef'.$contents; $body->rewind(); $body->write($contents); ``` -------------------------------- ### Psr\Http\Message\UriInterface Methods Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Interfaces.md Defines methods for retrieving and manipulating the components of a URI. ```APIDOC ## `Psr\Http\Message\UriInterface` Methods ### Description Defines methods for retrieving and manipulating the components of a URI. ### Methods - **`getScheme()`** - Description: Retrieve the scheme component of the URI. - **`getAuthority()`** - Description: Retrieve the authority component of the URI. - **`getUserInfo()`** - Description: Retrieve the user information component of the URI. - **`getHost()`** - Description: Retrieve the host component of the URI. - **`getPort()`** - Description: Retrieve the port component of the URI. - **`getPath()`** - Description: Retrieve the path component of the URI. - **`getQuery()`** - Description: Retrieve the query string of the URI. - **`getFragment()`** - Description: Retrieve the fragment component of the URI. - **`withScheme($scheme)`** - Description: Return an instance with the specified scheme. - **`withUserInfo($user, $password = null)`** - Description: Return an instance with the specified user information. - **`withHost($host)`** - Description: Return an instance with the specified host. - **`withPort($port)`** - Description: Return an instance with the specified port. - **`withPath($path)`** - Description: Return an instance with the specified path. - **`withQuery($query)`** - Description: Return an instance with the specified query string. - **`withFragment($fragment)`** - Description: Return an instance with the specified URI fragment. - **`__toString()`** - Description: Return the string representation as a URI reference. ``` -------------------------------- ### Prepend to Stream by Rewriting Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Usage.md Prepends content to a PSR-7 response body stream by reading its contents, rewinding, and writing new and original content. Ensure to rewind the stream before writing if you need to prepend. ```php // assuming our response body stream only contains: "abcd" $body = $response->getBody(); $body->rewind(); $contents = $body->getContents(); // abcd // seeking the stream to beginning $body->rewind(); $body->write('ef'); // stream contains "efcd" $body->write($contents); // stream contains "efabcd" ``` -------------------------------- ### Add File from PSR-7 Stream Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/PSR7Streams.rst Adds a file to the zip archive directly from a PSR-7 stream. Ensure the stream is readable. ```php $stream = $response->getBody(); // add a file named 'streamfile.txt' from the content of the stream $zip->addFileFromPsr7Stream( fileName: 'streamfile.txt', stream: $stream, ); ``` -------------------------------- ### Call Matrix Function via Static Method (Array) Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Call a matrix function using the static method of the Functions class, passing the grid array directly as an argument. No Matrix object instantiation is needed. ```php $grid = [ [16, 3, 2, 13], [ 5, 10, 11, 8], [ 9, 6, 7, 12], [ 4, 15, 14, 1], ]; echo Matrix\Functions::trace($grid); ``` -------------------------------- ### Validate All Code Changes Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/phpoffice/phpspreadsheet/CONTRIBUTING.md This command must be run to validate all code changes before submission. ```bash composer check ``` -------------------------------- ### Call Matrix Function via Object Method Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Call a matrix function by using the relevant method on a Matrix object. Ensure the Matrix class is instantiated. ```php $grid = [ [16, 3, 2, 13], [ 5, 10, 11, 8], [ 9, 6, 7, 12], [ 4, 15, 14, 1], ]; $matrix = new Matrix\Matrix($grid); echo $matrix->trace(); ``` -------------------------------- ### Create Complex Object from String Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Instantiate a Complex object by passing a string representation of a complex number to the constructor. ```php $complexString = '1.23-4.56i'; $complexObject = new Complex\Complex($complexString); ``` -------------------------------- ### Perform matrix multiplication using static method Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/matrix/README.md Multiply two matrices using the static multiply method from the Operations class. Arguments can be Matrix objects or arrays. ```php $matrix1 = new Matrix\Matrix([ [2, 7, 6], [9, 5, 1], [4, 3, 8], ]); $matrix2 = new Matrix\Matrix([ [1, 2, 3], [4, 5, 6], [7, 8, 9], ]); var_dump(Matrix\Operations::multiply($matrix1, $matrix2)->toArray()); ``` -------------------------------- ### Add Complex Numbers using Method Chaining Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Perform addition of two complex numbers by calling the add method on a Complex object. The method returns a new Complex object. ```php $complexString1 = '1.23-4.56i'; $complexString2 = '2.34+5.67i'; $complexObject = new Complex\Complex($complexString1); echo $complexObject->add($complexString2); ``` -------------------------------- ### Configure S3 Stream Context for Upload Permissions Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/Symfony.rst This snippet shows how to create a stream context for uploading files to S3 with specific permissions, such as 'public-read' ACL. This is crucial for ensuring correct file permissions when using S3 streams. ```php $path = "s3://{$adapter->getBucket()}/{$this->getArchivePath()}"; // the important bit $outputContext = stream_context_create([ 's3' => ['ACL' => 'public-read'], ]); fopen($path, 'w', null, $outputContext); ``` -------------------------------- ### Replace String with Simple String Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/composer/pcre/README.md Use Regex::replace to substitute a pattern with a fixed string. The result is accessed via the ->result property. ```php $newString = Regex::replace('{fo+}', 'bar', $string)->result; ``` -------------------------------- ### Disable Nginx Buffering with Custom Header Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/Nginx.rst Set the 'X-Accel-Buffering' header to 'no' to disable Nginx's response buffering. This is crucial for streaming large files efficiently with ZipStream-PHP. ```php header('X-Accel-Buffering', 'no'); ``` ```php $response->headers->set('X-Accel-Buffering', 'no'); ``` -------------------------------- ### Stream Zip Data to a Callback Function Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/README.md Stream ZIP data to a custom callback function for processing, such as writing to multiple files or sending to the browser. Ensure resources are cleaned up. ```php use ZipStream\ZipStream; use ZipStream\Stream\CallbackStreamWrapper; // Stream to a callback function with proper file handling $outputFile = fopen('output.zip', 'wb'); $backupFile = fopen('backup.zip', 'wb'); $zip = new ZipStream( outputStream: CallbackStreamWrapper::open(function (string $data) use ($outputFile, $backupFile) { // Handle ZIP data as it's generated fwrite($outputFile, $data); // Send to multiple destinations efficiently echo $data; // Browser fwrite($backupFile, $data); // Backup file }), sendHttpHeaders: false, ); $zip->addFile('hello.txt', 'Hello World!'); $zip->finish(); // Clean up resources close($outputFile); close($backupFile); ``` -------------------------------- ### Stream Zip Archive from AWS S3 using Symfony StreamedResponse Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/maennchen/zipstream-php/guides/Symfony.rst This snippet demonstrates how to stream files from an AWS S3 bucket as a zip archive directly to the user's browser using Symfony's StreamedResponse and ZipStream. It requires the AWS SDK for PHP and its Symfony integration. ```php use Symfony\Component\HttpFoundation\StreamedResponse; use Aws\S3\S3Client; use ZipStream; //... /** * @Route("/zipstream", name="zipstream") */ public function zipStreamAction() { // sample test file on s3 $s3keys = array( "ziptestfolder/file1.txt" ); $s3Client = $this->get('app.amazon.s3'); //s3client service $s3Client->registerStreamWrapper(); //required // using StreamedResponse to wrap ZipStream functionality // for files on AWS s3. $response = new StreamedResponse(function() use($s3keys, $s3Client) { // Define suitable options for ZipStream Archive. // this is needed to prevent issues with truncated zip files //initialise zipstream with output zip filename and options. $zip = new ZipStream\ZipStream( outputName: 'test.zip', defaultEnableZeroHeader: true, contentType: 'application/octet-stream', ); //loop keys - useful for multiple files foreach ($s3keys as $key) { // Get the file name in S3 key so we can save it to the zip //file using the same name. $fileName = basename($key); // concatenate s3path. // replace with your bucket name or get from parameters file. $bucket = 'bucketname'; $s3path = "s3://" . $bucket . "/" . $key; //addFileFromStream if ($streamRead = fopen($s3path, 'r')) { $zip->addFileFromStream( fileName: $fileName, stream: $streamRead, ); } else { die('Could not open stream for reading'); } } $zip->finish(); }); return $response; } ``` -------------------------------- ### Psr\Http\Message\ServerRequestInterface Methods Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Interfaces.md Provides methods for retrieving and manipulating server request specific data, including server parameters, cookies, query parameters, uploaded files, parsed body, and attributes. ```APIDOC ## `Psr\Http\Message\ServerRequestInterface` Methods ### Description Provides methods for retrieving and manipulating server request specific data, including server parameters, cookies, query parameters, uploaded files, parsed body, and attributes. ### Methods - **`getServerParams()`** - Description: Retrieve server parameters. - Notes: Typically derived from `$_SERVER`. - **`getCookieParams()`** - Description: Retrieves cookies sent by the client to the server. - Notes: Typically derived from `$_COOKIES`. - **`withCookieParams(array $cookies)`** - Description: Returns a new request instance with the specified cookies. - **`withQueryParams(array $query)`** - Description: Returns a new request instance with the specified query string arguments. - **`getUploadedFiles()`** - Description: Retrieve normalized file upload data. - **`withUploadedFiles(array $uploadedFiles)`** - Description: Returns a new request instance with the specified uploaded files. - **`getParsedBody()`** - Description: Retrieve any parameters provided in the request body. - **`withParsedBody($data)`** - Description: Returns a new request instance with the specified body parameters. - **`getAttributes()`** - Description: Retrieve attributes derived from the request. - **`getAttribute($name, $default = null)`** - Description: Retrieve a single derived request attribute. - **`withAttribute($name, $value)`** - Description: Returns a new request instance with the specified derived request attribute. - **`withoutAttribute($name)`** - Description: Returns a new request instance that without the specified derived request attribute. ``` -------------------------------- ### Calling sinh() using Complex object method Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Demonstrates calling the sinh() function directly on a Complex object instance. ```php $complexString = '1.23-4.56i'; $complexObject = new Complex\Complex($complexString); echo $complexObject->sinh(); ``` -------------------------------- ### Ensuring non-nullable match groups Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/composer/pcre/README.md Uses variants that guarantee match groups are always present, throwing an exception if a subpattern does not match. ```php use Composer\Pcre\Preg; // $matches is guaranteed to be an array of strings, if a subpattern does not match and produces a null it will throw if (Preg::matchStrictGroups('{fo+}', $string, $matches)) if (Preg::matchAllStrictGroups('{fo+}', $string, $matches)) ``` -------------------------------- ### Run Redirect Cleanup Cronjob Source: https://github.com/sterc/seosuite/blob/master/readme.md Execute the redirect cleanup cronjob script to remove old, unresolved redirects. You can specify a cutoff date and the maximum number of triggers. ```bash php redirect-cleanup.php --till=2018-11-23 --triggered=2 ``` -------------------------------- ### Combined SeoSuiteMeta Placeholders Source: https://github.com/sterc/seosuite/blob/master/readme.md This snippet provides a single placeholder to retrieve all combined metadata. It is useful when you need a consolidated output of all SEO meta tags. ```html [[!+ss_meta]] ``` -------------------------------- ### Psr\Http\Message\ResponseInterface Methods Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Interfaces.md Provides methods for retrieving and manipulating HTTP response data, including status code and reason phrase. ```APIDOC ## `Psr\Http\Message\ResponseInterface` Methods ### Description Provides methods for retrieving and manipulating HTTP response data, including status code and reason phrase. ### Methods - **`getStatusCode()`** - Description: Gets the response status code. - **`withStatus($code, $reasonPhrase = '')`** - Description: Returns a new response instance with the specified status code and, optionally, reason phrase. - **`getReasonPhrase()`** - Description: Gets the response reason phrase associated with the status code. ``` -------------------------------- ### Add Complex Numbers using Static Operation Method Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Perform addition of two complex numbers using the static add method from the Operations class. This method can accept string representations of complex numbers. ```php $complexString1 = '1.23-4.56i'; $complexString2 = '2.34+5.67i'; echo Complex\Operations::add($complexString1, $complexString2); ``` -------------------------------- ### Create Complex Object from Array Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/markbaker/complex/README.md Instantiate a Complex object by passing an array of real, imaginary, and suffix values to the constructor. ```php $real = 1.23; $imaginary = -4.56; $suffix = 'i'; $arguments = [$real, $imaginary, $suffix]; $complexObject = new Complex\Complex($arguments); ``` -------------------------------- ### UploadedFileInterface Methods Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Interfaces.md Provides access to information and operations related to an uploaded file. ```APIDOC ## UploadedFileInterface ### Description Represents an uploaded file in an HTTP request, providing methods to access its properties and manage its storage. ### Methods #### `getStream()` ##### Description Retrieve a stream representing the uploaded file. ##### Return - **`Psr\Http\Message\StreamInterface`** - A stream of the uploaded file. #### `moveTo($targetPath)` ##### Description Move the uploaded file to a new location. ##### Parameters #### Path Parameters - **`$targetPath`** (string) - Required - The target path to move the file to. #### `getSize()` ##### Description Retrieve the file size. ##### Return - **`int|null`** - The size of the file in bytes, or null if the size cannot be determined. #### `getError()` ##### Description Retrieve the error associated with the uploaded file. ##### Return - **`int`** - An error code constant (e.g., `UPLOAD_ERR_OK`). #### `getClientFilename()` ##### Description Retrieve the filename sent by the client. ##### Return - **`string|null`** - The filename, or null if not available. #### `getClientMediaType()` ##### Description Retrieve the media type sent by the client. ##### Return - **`string|null`** - The media type, or null if not available. ``` -------------------------------- ### Psr\Http\Message\RequestInterface Methods Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/psr/http-message/docs/PSR7-Interfaces.md Extends MessageInterface with methods specific to HTTP requests, including retrieving and manipulating the request target, method, and URI. ```APIDOC ## `Psr\Http\Message\RequestInterface` Methods *Same methods as `Psr\Http\Message\MessageInterface` + the following methods:* ### `getRequestTarget()` **Description**: Retrieves the message's request target. **Notes**: origin-form, absolute-form, authority-form, asterisk-form ([RFC7230](https://www.rfc-editor.org/rfc/rfc7230.txt)) ### `withRequestTarget($requestTarget)` **Description**: Return a new message instance with the specific request-target. ### `getMethod()` **Description**: Retrieves the HTTP method of the request. **Notes**: GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE (defined in [RFC7231](https://tools.ietf.org/html/rfc7231)), PATCH (defined in [RFC5789](https://tools.ietf.org/html/rfc5789)) ### `withMethod($method)` **Description**: Returns a new message instance with the provided HTTP method. ### `getUri()` **Description**: Retrieves the URI instance. ### `withUri(UriInterface $uri, $preserveHost = false)` **Description**: Returns a new message instance with the provided URI. **Notes**: ``` -------------------------------- ### Using Regex class for result objects Source: https://github.com/sterc/seosuite/blob/master/core/components/seosuite/vendor/composer/pcre/README.md Utilizes the Regex class for operations that return result objects instead of by-reference arguments. ```php use Composer\Pcre\Regex; // this is useful when you are just interested in knowing if something matched // as it returns a bool instead of int(1/0) for match $bool = Regex::isMatch('{fo+}', $string); $result = Regex::match('{fo+}', $string); if ($result->matched) { something($result->matches); } $result = Regex::matchWithOffsets('{fo+}', $string); if ($result->matched) { something($result->matches); } $result = Regex::matchAll('{fo+}', $string); if ($result->matched && $result->count > 3) { something($result->matches); } ```