Download the PHP package daun/statamic-cache-directives without Composer

On this page you can find all versions of the php package daun/statamic-cache-directives. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package statamic-cache-directives

Statamic Cache Directives

Parse conditional HTML comment directives after Statamic has rendered a page, so cached pages can still include small dynamic fragments.

This package is a lightweight alternative to Statamic's nocache tag. It is useful for tiny auth-, role-, or request-dependent islands where you only need to keep or remove existing markup without the overhead of the nocache data/session pipeline.

It is implemented as a static caching replacer for Statamic's half-measure static cache.

Installation

Install the package via composer:

Registration

Enable the replacer in config/statamic/static_caching.php.

Usage

Wrap markup in conditional comments. Matching blocks are kept when their expression evaluates to true; otherwise they are removed from the response.

The second format follows the downlevel-hidden syntax for conditional comments.

Syntax

Expressions use Symfony Expression Language syntax.

If

Unless

Not

Use either ! or not.

And

Use and or &&.

Or

Use or or ||.

Echo

Use echo to print a variable value. Echo directives can be standalone or block-style. Output is escaped for html contexts.

Raw

Use raw to print a variable value without escaping. Use this only for values you fully control as printing untrusted data with raw is an XSS vector.

Combined expressions

Use parentheses to group subexpressions or override precedence.

Nested data and object methods

Use [] for array keys and . for object properties or methods.

Unknown variable names throw an InvalidArgumentException, so typos fail loudly.

Built-in variables

These variables are available by default and can be used in expressions:

Authentication uses Statamic's configured control-panel guard: config('statamic.users.guards.cp').

Real-world examples

Seed frontend auth state

Swap account navigation without nocache

Show edit links to super admins

Hide conversion prompts from signed-in users

Load control-panel JavaScript

Custom variables

Add custom variables during application boot using variable() or variables(). Values can be scalar values, arrays, objects or closures. Closures are evaluated lazily when the variable is first encountered.

Use closures for request-dependent values such as auth, session, request data, or GeoIP lookups. In long-lived worker runtimes such as FrankenPHP, Swoole, RoadRunner, or Laravel Octane, service providers can boot once per worker instead of once per request. Passing a direct value would capture the value at boot; passing a closure resolves it for the current request.

For bulk registration, use variables().

Then use those variables in comments:

Disabling a response

If a response contains this marker anywhere, directive parsing is skipped for the whole response. Use it as a kill switch on routes that must never be processed (for example email or preview endpoints).

Ignoring a range

Wrap a section in ignore markers to leave it verbatim while the rest of the response is still parsed. Directives inside the range are not processed, and the wrapper comments are removed from the output. This is useful for fragments that legitimately contain conditional comments (for example Outlook <!--[if mso]> markup) or documentation showing directive syntax.

[!WARNING] Both markers control directive processing, so they must never originate from untrusted, user-controlled content. See Security below.

Security

This replacer scans the entire cached HTML response for directive comments. Cached pages frequently contain user-generated content (comments, reviews, usernames, profile fields, reflected search queries, form echoes). If any of that content can contain the strings below, it can subvert directive processing:

To stay safe, strip or neutralize directive comments from user-controlled content before it is rendered into a cacheable page. For example, remove <!--[ sequences from user input, or escape them:

Failure handling:

License

MIT


All versions of statamic-cache-directives with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
statamic/cms Version ^5.0 || ^6.0
symfony/expression-language Version ^7.4 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package daun/statamic-cache-directives contains the following files

Loading the files please wait ...