Exemple #1
0
<?php

if (!isset($_SERVER['argv'][1])) {
    echo 'Usage: php scripts/php-minify.php class.list', PHP_EOL;
    die;
}
$rootPath = dirname(__FILE__) . '/..';
set_include_path(implode(PATH_SEPARATOR, array(realpath($rootPath . '/library'), get_include_path())));
$loader = new CLoader();
$loader->process($_SERVER['argv'][1]);
class CLoader
{
    protected $classes = array();
    protected $outputFile = 'full.php';
    public function process($fileName)
    {
        if (!file_exists($fileName)) {
            die('Error: ' . $fileName . " do not exists" . PHP_EOL);
        }
        file_put_contents($this->outputFile, "<?php \n", LOCK_EX);
        foreach (file($fileName) as $name) {
            $loader->loadClass($name);
        }
    }
    public function loadClass($name)
    {
        $namePart = explode('_', trim($name));
        if (in_array($name, $this->classes)) {
            return;
        }
        if (in_array($namePart[0], array('Zend', 'System'))) {