This modules is intended to provide roughly the same functionality as the apc.php
that shipps with the documentation of the Alternative PHP Cache. The goal is to take a peek at the inner workings of APC and monitor things like cache usage, memory fragmentation etc.
This extension comes as a module as this is the easiest way to provide all the funcionality in one drop. However, it should be possible to rename and/or even relocate the main controller.
Please take note that this modules does not check for authentication or authorization in any way since I cannot make any assumptions of the auth mechanisms in other's applications. Please see to it that you grant permissions on this module only to the appropriate entities.
Also: This module is still a work-in-progress. So any kind of feedback is very welcome.
Requirements ¶
- Yii v1.1.x
- APC
- Possibly the liquid plugin for the Blueprint CSS framework
Usage ¶
This extension can be used as a drop-in module. Just follow these steps:
- Unzip the content of the ZIP to your
application.modules
directory - Find the
modules
-stanza (create it if it doesn't exist yet) in your config and add theapcinfo
module like this:
'modules' => array(
...,
'apcinfo',
),
- Enjoy! :)
Changes ¶
v0.9 (December 20th, 2011) ¶
- Initial Release
v0.91 (December 22nd, 2011) ¶
- Fixed a bug that prevented entires in the usercache to be viewed and deleted when the application used filepath-style URLs
- Serialized entries in the usercache will now be unserialized for display
v0.92 (March 23rd, 2012) ¶
- Display cache fragmentation
- Full caches are now more notable
Resources ¶
- Forum: Discussion thread
- Github: yii-apcinfo
- Wiki: Getting the Most out of APC for Yii
Remove default controller
Nice extension! Very helpful in configuring and evaluating APC. :)
A small improvement suggestion: remove the DefaultController and simply configure ApcinfoModule->defaultController.
RE: Remove default controller
Thanks for the suggestion, I'll definitely consider it. The sole purpose of the
DefaultController
atm is to provide a hassle-free entry point for the module anyway.Bootstrap progress bar
Also to the author.. thanks for this ext. it's pretty awesome. I only have one real suggestion is that you put all of the css in one file so you're not publishing 3 files with very little css in them.
I'm using this bootstrap extension
I figured I'd share a portion of my code if anyone else is using this extension and bootstrap...
Make sure you include bootstrap in the top of your views/apc/index.php file or it won't display the css
<?php Yii::app()->bootstrap->register(); ?>
change
<div class="fragmentation-container"> <?php foreach($blocks as $block) echo CHtml::tag('div', array( 'class'=>$block['free'] ? 'free' : 'used', 'style'=>'width: '.(int)$block['percent'].'%', 'title'=>($block['free'] ? 'Free' : 'Used') . " block with {$formatter->formatDatasize($block['size'])} (Segment {$block['segment']} | Offset {$formatter->formatNumber($block['offset'])})", ), '', true); ?> </div> <div class="right" style="font-weight: bold;"> Fragmentation: <?php if($fragInfo['freesegs'] > 1): ?> <span title="<?php echo $formatter->formatDatasize($fragInfo['fragsize']); ?> out of <?php echo $formatter->formatDatasize($fragInfo['freetotal']);?> in <?php echo $fragInfo['freesegs']; ?> segments"><?php echo round($fragInfo['fragsize']/$fragInfo['freetotal']*100, 3); ?>%</span> <?php else: ?> 0.00% <?php endif; ?> </div> <?php $this->endWidget(); ?>
To
<?php $this->beginWidget('zii.widgets.CPortlet', array( 'title'=>'<span class="icon-minus"></span> Cache Fragmentation', )); ?> <?php $usedfrag = $fragInfo['fragsize']; $totalfrag = $fragInfo['freetotal']; $fragtotalspace = round($usedfrag/$totalfrag*100, 3); $this->widget('bootstrap.widgets.TbProgress', array( 'type'=>'danger', // 'info', 'success' or 'danger' 'percent'=>$fragtotalspace, // the progress 'striped'=>true, 'animated'=>true, 'htmlOptions'=> array('style'=>'height: 20px; margin-bottom:5px; -moz-box-shadow: inset 0 0 1px #000000; -webkit-box-shadow: inset 0 0 1px #000000; box-shadow: inset 0 0 1px #000000;'), )); ?> <div class="right" style="font-weight: bold;"> Fragmentation: <?php if($fragInfo['freesegs'] > 1): ?> <span title="<?php echo $formatter->formatDatasize($fragInfo['fragsize']); ?> out of <?php echo $formatter->formatDatasize($fragInfo['freetotal']);?> in <?php echo $fragInfo['freesegs']; ?> segments"><?php echo round($fragInfo['fragsize']/$fragInfo['freetotal']*100, 3); ?>%</span> <?php else: ?> 0.00% <?php endif; ?> </div> <?php $this->endWidget(); ?>
you could also do something like this if you want it to change colors based on a percentage.
<div class"test" style="width:100%; margin: 0 0 1% 0;"> <?php $this->beginWidget('zii.widgets.CPortlet', array( 'title'=>'<span class="icon-minus"></span> Cache Fragmentation', )); $usedfrag = $fragInfo['fragsize']; $totalfrag = $fragInfo['freetotal']; $fragtotalspace = round($usedfrag/$totalfrag*100, 3); if ($fragtotalspace < 50) { $this->widget('bootstrap.widgets.TbProgress', array( 'type'=>'success', // 'info', 'success' or 'danger' 'percent'=>$fragtotalspace, // the progress 'striped'=>true, 'animated'=>true, 'htmlOptions'=> array('style'=>'height: 20px; margin-bottom:5px; -moz-box-shadow: inset 0 0 1px #000000; -webkit-box-shadow: inset 0 0 1px #000000; box-shadow: inset 0 0 1px #000000;'), )); } elseif($fragtotalspace >= 50 && $fragtotalspace < 75) { $this->widget('bootstrap.widgets.TbProgress', array( 'type'=>'warning', // 'info', 'success' or 'danger' 'percent'=>$fragtotalspace, // the progress 'striped'=>true, 'animated'=>true, 'htmlOptions'=> array('style'=>'height: 20px; margin-bottom:5px; -moz-box-shadow: inset 0 0 1px #000000; -webkit-box-shadow: inset 0 0 1px #000000; box-shadow: inset 0 0 1px #000000;'), )); } else { $this->widget('bootstrap.widgets.TbProgress', array( 'type'=>'danger', // 'info', 'success' or 'danger' 'percent'=>$fragtotalspace, // the progress 'striped'=>true, 'animated'=>true, 'htmlOptions'=> array('style'=>'height: 20px; margin-bottom:5px; -moz-box-shadow: inset 0 0 1px #000000; -webkit-box-shadow: inset 0 0 1px #000000; box-shadow: inset 0 0 1px #000000;'), )); } ; ?>
You would also want to get rid of fragmentation.css file and the line that includes the css file
<?php Yii::app()->getClientScript()->registerCssFile($this->module->getAssetsUrl() . '/fragmentation.css'); ?>
in the _fragmentation.php file line 1
Here is a screen shot Note: the progress bar isn't right compared to the fragmentation % I altered it for the screen shot so you can see it in action.
RE: Bootstrap progress bar
Well, thanks for your suggestion. The sole reason for the split of the CSS code has really been to leverage customized layouts (so you could e.g. have the index page split over three pages). For the 1.0 release, I plan to reorganize most of the code into standalone widgets and reloacatable actions, so everything can be integrated into existing dashboards nicely.
As for your work: Congratulations! Looks really nice ;) I'll see if I can aid by supplying a bootstrap theme in the next release.
Keep the default controller
Personally I like that you have the default controller and redirect away from it.
This way you don't have multiple urls for the same thing.
'apcinfo/apc/index' and 'apcinfo/'
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.