• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flush output data

#1
Sad 
Good guys

The problem is that I can not make the information of a sequence of processes within a function, feed back to the user.


PHP Code:
echo "Data 1 Done";
flush();
ob_flush();
sleep(1);

echo 
"Data 2 Done";
flush();
ob_flush();
sleep(1);

echo 
"Data 3 Done";
flush();
ob_flush();
sleep(1); 
Some idea of how to do this, either to use with ajax or simply to show the sequence in the view. Thank you
Reply

#2
Some anti-virus programs can interfere with the flush.

You can try this to see if it works, not tested here.

PHP Code:
ob_start();

echo 
"Data 1 Done";

flush();
ob_flush();

sleep(1);

ob_end_flush();
ob_end_clean();

echo 
"Data 2 Done";

flush();
ob_flush();

sleep(1);

ob_end_flush();
ob_end_clean(); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(01-06-2018, 11:34 PM)InsiteFX Wrote: Some anti-virus programs can interfere with the flush.

You can try this to see if it works, not tested here.

PHP Code:
ob_start();

echo 
"Data 1 Done";

flush();
ob_flush();

sleep(1);

ob_end_flush();
ob_end_clean();

echo 
"Data 2 Done";

flush();
ob_flush();

sleep(1);

ob_end_flush();
ob_end_clean(); 

nothing, it still does not work, it launches the lines once the process is finished, I imagine it must be something with the output library, but I can not find a way to manually manipulate this output in the CI internal buffer.

Try doing it using a helper, but it did not work anyway:

helper:
PHP Code:
if ( ! function_exists('mataBufer')){

 
   function mataBufer(){

 
       $CI =& get_instance();

 
       echo $CI->output->get_output();

 
       @ob_end_flush();
 
       ob_implicit_flush(TRUE);

 
       echo '<div>' str_repeat('&nbsp;'170) . '</div>';

 
   }



but when calling the helper nothing happens, it keeps showing the finished output.

There will be some real way in codeigniter to be able to achieve this, since it is a function that is sometimes vital for informing the user about the progress of a long process that is making our application.

Codeigniter is an excellent framework, very functional, with a low learning curve and quite flexible to personalization, but not solve this small nonsense, it seems absurd.
Reply

#4
You could display a progress bar using jQuery or JavaScript.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#5
(01-07-2018, 12:11 PM)InsiteFX Wrote: You could display a progress bar using jQuery or JavaScript.

At that point I am clear, what I need to do is inform jquery or the user by the method that is at which point of the execution is the process, for example:

> Starting Installation ...
// After a few seconds and completing the necessary functions ...

> Complete installation
> Installing Resources ...
// After a few seconds and completing the necessary functions ...

> Installed Resources
> Registering Components ...
// After a few seconds and completing the necessary functions ...

> All Processes Completed

The problem is that if, for example, I require that some databases be created, some data be recorded in these tables, create some files among others, it would be good to inform the user at what point the installation goes, for example and not a white screen while everything is finished.
No SEO spam
Reply

#6
Starting Installation   - Show progress bar
Complete installation - Installing Resources ... Show another progress bar
Installed Resources   - Registering Components ... Show a progress bar

To me each step should have it's own progress bar.

NProgress.js

jQMeter

Bootstrap Progressbar
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.