Code Monkey home page Code Monkey logo

fluid-stream-buffer's Introduction

Render huge fluid views to a stream resource

This is an attempt to render huge fluid views with low memory footprint.

Fluid snippets are passed to PHP resource streams in between to have them not appear in the result string of the overall view. Instead, placeholder strings are added to the result string. A worker called Container walks through the result template, replaces the placeholder strings by the actual contents and passes the combined result to another resource stream.

Tests show a single fluid result of over 100MB overall can be created with only 1MB of PHP memory footprint.

<?php

use StephanSchuler\FluidStreamBuffer\Stream\Container;

$view = new TYPO3Fluid\Fluid\View\TemplateView();

$stream = Container::create()
    ->renderView($view)
    ->toResourceStream();

assert(get_resource_type($stream) === 'stream');

print_r(
    fstat(
        $stream
    )
);

/**
 * Array
 * (
 *     [0] => 16777223
 *     [1] => 31874556
 *     [2] => 33152
 *     [3] => 1
 *     [4] => 942230658
 *     [5] => 635458030
 *     [6] => 0
 *     [7] => 116746983
 *     [8] => 1575327606
 *     [9] => 1575327607
 *     [10] => 1575327607
 *     [11] => 4096
 *     [12] => 228024
 *     [dev] => 16777223
 *     [ino] => 31874556
 *     [mode] => 33152
 *     [nlink] => 1
 *     [uid] => 942230658
 *     [gid] => 635458030
 *     [rdev] => 0
 *     [size] => 116746983
 *     [atime] => 1575327606
 *     [mtime] => 1575327607
 *     [ctime] => 1575327607
 *     [blksize] => 4096
 *     [blocks] => 228024
 * )
 */

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.