Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Zend Cache Laravel Package

zendframework/zend-cache

zendframework/zend-cache provides flexible caching for PHP apps with multiple storage backends (filesystem, memory, APCu, Redis, and more). Supports cache patterns, plugins, serialization, and configurable adapters to improve performance and reduce repeated work.

View on GitHub
Deep Wiki
Context7

CaptureCache

The CaptureCache pattern is useful for generating static resources to return via HTTP request. When used in such a fashion, the web server needs to be configured to run a PHP script generating the requested resource so that subsequent requests for the same resource can be shipped without calling PHP again.

This pattern comes with basic logic for managing generated resources.

Quick Start

For use with an Apache 404 handler:

# .htdocs
ErrorDocument 404 /index.php
// index.php
use Zend\Cache\PatternFactory;
$capture = Zend\Cache\PatternFactory::factory('capture', [
    'public_dir' => __DIR__,
]);

// Start capturing all output, excluding headers, and write to the public
// directory:
$capture->start();

// Don't forget to change the HTTP response code
header('Status: 200', true, 200);

// do stuff to dynamically generate output

Configuration Options

Option Data Type Default Value Description
public_dir string none Location of the public web root directory in which to write output.
index_filename string "index.html" The name of the index file if only a directory was requested.
file_locking bool true Whether or not to lock output files when writing.
file_permission `int bool` 0600 (false on Windows)
dir_permission `int bool` 0700 (false on Windows)
umask int bool false

Available Methods

In addition to the methods exposed in PatternInterface, this implementation exposes the following methods.

namespace Zend\Cache\Pattern;

use Zend\Cache\Exception;
use Zend\Stdlib\ErrorHandler;

class CaptureCache extends AbstractPattern
{
    /**
     * Start the cache.
     *
     * [@param](https://github.com/param)  string $pageId  Page identifier
     * [@return](https://github.com/return) void
     */
    public function start($pageId = null);

    /**
     * Write a page to the requested path.
     *
     * [@param](https://github.com/param) string      $content
     * [@param](https://github.com/param) null|string $pageId
     * [@throws](https://github.com/throws) Exception\LogicException
     */
    public function set($content, $pageId = null);

    /**
     * Retrieve a generated page from the cache.
     *
     * [@param](https://github.com/param)  null|string $pageId
     * [@return](https://github.com/return) string|null
     * [@throws](https://github.com/throws) Exception\LogicException
     * [@throws](https://github.com/throws) Exception\RuntimeException
     */
    public function get($pageId = null);

    /**
     * Check if a cache exists for the given page.
     *
     * [@param](https://github.com/param)  null|string $pageId
     * [@throws](https://github.com/throws) Exception\LogicException
     * [@return](https://github.com/return) bool
     */
    public function has($pageId = null);

    /**
     * Remove a page from the cache.
     *
     * [@param](https://github.com/param)  null|string $pageId
     * [@throws](https://github.com/throws) Exception\LogicException
     * [@throws](https://github.com/throws) Exception\RuntimeException
     * [@return](https://github.com/return) bool
     */
    public function remove($pageId = null);

    /**
     * Clear cached pages that match the specified glob pattern.
     *
     * [@param](https://github.com/param) string $pattern
     * [@throws](https://github.com/throws) Exception\LogicException
     */
    public function clearByGlob($pattern = '**');

    /**
     * Returns the generated file name.
     *
     * [@param](https://github.com/param) null|string $pageId
     * [@return](https://github.com/return) string
     */
    public function getFilename($pageId = null);
}

Examples

Scaling Images in the Web Root

Using the following Apache 404 configuration:

# .htdocs
ErrorDocument 404 /index.php

Use the following script:

// index.php
$captureCache = Zend\Cache\PatternFactory::factory('capture', [
    'public_dir' => __DIR__,
]);

// TODO
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport