Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9238347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:44:26+00:00 2026-06-18T07:44:26+00:00

I am working in a MVC pattern situation here. I have index.php as a

  • 0

I am working in a MVC pattern situation here.

I have index.php as a base file, controllers located in /controllers/ directory. If you go to /stream/xIEjeEJWqs for example /controllers/streamcontroller.php will be executed.

index.php starts like this and it minifies an output that is about to be sent to browser:

<?php

function replace_tabs_newlines($content)
{
    require_once 'includes/min/lib/Minify/HTML.php';
    require_once 'includes/min/lib/Minify/CSS_MODIFIED.php';
    require_once 'includes/min/lib/JSMin.php';
    $content = Minify_HTML::minify($content, array(
        'cssMinifier' => array('Minify_CSS', 'minify'),
        'jsMinifier' => array('JSMin', 'minify')
    ));
    return $content;
}

ob_start('replace_tabs_newlines');
ob_implicit_flush(0);
...

So this code minfies whatever is being outputted, like this:

<html>
    <head>
        <title>
            Minifies..
        </title>

becomes <html><head><title>Minifies..</title>

So, problem is that streamcontroller.php has to output something as PNG, MP4, and other and when it readfile()-s a content, browser cannot recognize a content which is compressed by index.php in the beginning.

Extract from streamcontroller.php:

case "png":
  header('Content-type:image/png');
  header('Content-Length: ' . filesize($file));     
  readfile($file);
  exit;
break;

Now my questions are following:

  1. What would you recommend, taking out streamcontroller.php from MVC? Having streamer.php next to index.php for example?

  2. Adding check functionanility in index.php‘s replace_tabs_newlines($content) function to check if browser is pointing at streamcontroller.php and do not do a minify job?

  3. Maybe there is a way to stop ob_start()‘s callback from being exacuted while being about to output something? ie: before readfile() in streamcontroller.php?

  4. I will appreciate new ideas that are quite accepted in situations like this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:44:28+00:00Added an answer on June 18, 2026 at 7:44 am

    How about adding an ob_end_clean before the readfile

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on mvc project, with repository pattern and entity framework, now on
I've been working with the MVC pattern for a while now, but I honestly
In an application I'm working on I've implemented a MVC pattern to use different
I'm a PHP developer, and I use the MVC pattern and object-oriented code. I
I'm working on the MVC Pattern Winforms example project from this website Program.cs static
I'm new to the MVC pattern but have been trying to grasp it, for
I'm working on a new php project with CodeIgniter and I have few questions
I am working on updating to a more manageable repository pattern in my MVC
I am working with ExtJS 4.1 RC3 - following the MVC pattern. Today was
So I have a desktop application designed using the MVC pattern inspired by this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.