slav123 / CodeIgniter-minify

CodeIgniter minify library CSS and JavaScript compression on the fly
MIT License
226 stars 86 forks source link

A PHP Error was encountered #8

Closed ghost closed 10 years ago

ghost commented 10 years ago

I'm testing your library with your example css and js files and when it generate the minified files I get this errors but the files are correctly generated.

I'm working with codeigniter 2.2.0.

A PHP Error was encountered

Severity: Notice

Message: Undefined index: css

Filename: libraries/Minify.php

Line Number: 224

A PHP Error was encountered

Severity: Notice

Message: Undefined index: css

Filename: libraries/Minify.php

Line Number: 224

A PHP Error was encountered

Severity: Notice

Message: Undefined index: js

Filename: libraries/Minify.php

Line Number: 224

A PHP Error was encountered

Severity: Notice

Message: Undefined index: js

Filename: libraries/Minify.php

Line Number: 224

slav123 commented 10 years ago

can you show me your example code ?

On Sunday, 6 July 2014 at 1:54 am, mario22792 wrote:

Im testing your library with your example css and js files and when it generate the minified files I get this errors but the files are correctly generated. A PHP Error was encountered Severity: Notice Message: Undefined index: css Filename: libraries/Minify.php Line Number: 224 A PHP Error was encountered Severity: Notice Message: Undefined index: css Filename: libraries/Minify.php Line Number: 224 A PHP Error was encountered Severity: Notice Message: Undefined index: js Filename: libraries/Minify.php Line Number: 224 A PHP Error was encountered Severity: Notice Message: Undefined index: js Filename: libraries/Minify.php Line Number: 224

— Reply to this email directly or view it on GitHub (https://github.com/slav123/CodeIgniter-minify/issues/8).

ghost commented 10 years ago

This is the code of my controller

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

/**
 * Index Page for this controller.
 *
 * Maps to the following URL
 *      http://example.com/index.php/welcome
 *  - or -  
 *      http://example.com/index.php/welcome/index
 *  - or -
 * Since this controller is set as the default controller in 
 * config/routes.php, it's displayed at http://example.com/
 *
 * So any other public methods not prefixed with an underscore will
 * map to /index.php/welcome/<method_name>
 * @see http://codeigniter.com/user_guide/general/urls.html
 */
public function index()
{
    $this->load->library('minify'); 
    $this->load->library('cache_fragment');
    $data['prueba'] = "hola";
    $this->load->view('welcome_message', $data);
}

}

And this is the code of my view

Welcome to CodeIgniter minify->css(array('browser-specific.css', 'style.css')); $this->minify->js(array('helpers.js', 'jqModal.js')); echo $this->minify->deploy_css(); echo $this->minify->deploy_js(); ?> ```
ghost commented 10 years ago

I correct this problem, is because on line 79 on Minify.php when yo do private $_lmod = array('css', 'js'); and the minified files don't exists the array contain:

0 => css, 1=> js

On line 136 you have to css this and the same to js:

if (!file_exists($this->css_file)) { if (!touch($this->css_file)) { die("Can't create file {$this->css_file}"); } } else { $this->_lmod['css'] = filemtime($this->css_file); } }

Then when you don't have the minified files the index css and js of $_lmod doesn't exist, to correct this i only change the line 79 and all work correct.

private $_lmod = array('css'=>"", 'js'=>"");

slav123 commented 10 years ago

You are correct ! I made update to source code.

https://github.com/slav123/CodeIgniter-minify/commit/c92d23276dc03498f5dd9dcf6d69b44151ba30dd