Giter VIP home page Giter VIP logo

Comments (23)

sourjya avatar sourjya commented on May 14, 2024

Hello, I'm facing the exact same problem :O all my paths are configured correctly and present (write permission isn't an issue as I'm on Windows+xampp). Routes have been setup properly. I'm using Cake 1.3 and the most recent download of assetCompress. Still files don't get written out..

The script inclusion line looks like this:
<script type="text/javascript" src="/cache_js/84525ff3fb5b308739f84ab10729b39d.js?file[]=jquery/jquery-1.4.4_min&file[]=jquery/plugins/jquery.validate-1.7_min"></script>

... but if I follow that link, I only get to a blank page.

Here's my ini file:

[Javascript]
searchPaths[] = WEBROOT/js/
searchPaths[] = WEBROOT/js/jquery/
searchPaths[] = WEBROOT/js/jquery/plugins/
stripComments = true
cacheFilePath = WEBROOT/cache_js/
cacheFiles = true
filters[] = JsMin
timestamp = true
[Css]
searchPaths[] = WEBROOT/css/
stripComments = true
cacheFilePath = WEBROOT/cache_css/
cacheFiles = true
filters[] = CssMin
timestamp = true

What are we missing out on ?

from asset_compress.

DarrenN avatar DarrenN commented on May 14, 2024

I'm currently trying to troubleshoot this, and have some additional questions.

One problem is that we need to be in Debug 0 to get the caching, which switches off error messages. I've notice that you're using PHP5 exception handling throughout the plugin. Cake doesn't currently catch these exceptions, is there something I can drop into AppController or AppError to round these up while in Debug 0 to aid in problem solving?

from asset_compress.

markstory avatar markstory commented on May 14, 2024

You can always use set_exception_handler() to create an exception handler that allows you to log the errors. There are only a few exceptions that the plugin raises surrounding, caching. Most of them are related to the cacheFilePath not being writable.

from asset_compress.

DarrenN avatar DarrenN commented on May 14, 2024

Okay thanks for that tip, starting to get somewhere now.

  1. The initial problem was that Nginx was attempting to serve the content of /cache_js/ directly without passing it through CakePHP (I have Nginx in front of Apache to serve static content, perhaps mention this as a gotcha in readme?)

  2. Once I got that cleared up I'm getting the following exception thrown in the Plugin itself:

Fatal error: Class 'Folder' not found in /path/to/app/plugins/asset_compress/models/asset_compressor.php on line 89

Line 89 : https://github.com/markstory/asset_compress/blob/master/models/asset_compressor.php#L89

from asset_compress.

DarrenN avatar DarrenN commented on May 14, 2024

To expand on the above error:

I dropped this above line 89 die(CAKE_CORE_INCLUDE_PATH) which returned the correct Cake include path (in my case /usr/local/cakephp_1_3)

When I tried to force include the class using App::import('Core','Folder'); it just crashed completely.

from asset_compress.

sourjya avatar sourjya commented on May 14, 2024

Okay. I thought of trying without the filters to see if the concatenated file is being generated at all.

Now my pages contain a line that looks like:
<script type="text/javascript" src="/cache_js/default.js?file[]=jquery/jquery-1.4.4_min&file[]=jquery/plugins/jquery.validate-1.7_min"></script>

And when I follow the link in src, it gets me to a blank page with the following error message:


Fatal error: JsFilesController::get() [<a href='http://php.net/jsfilescontroller.get'>jsfilescontroller.get</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition &quot;JsFile&quot; of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in D:\xampp\htdocs\stiu\app\plugins\asset_compress\controllers\js_files_controller.php on line 43

Any ideas what/where is going wrong?

Thanks.

from asset_compress.

markstory avatar markstory commented on May 14, 2024

I've not seen that error before. Are you using persistModel or something?

from asset_compress.

DarrenN avatar DarrenN commented on May 14, 2024

No persistModel on my end, but I am using the MongoDB datasource.

from asset_compress.

leohidalgo avatar leohidalgo commented on May 14, 2024

I'm using version 0.6 of the plugin and Cake 2.1 and I not storing in the cache directory.

Any idea who might be failing?

Greetings.

from asset_compress.

markstory avatar markstory commented on May 14, 2024

R0cKET: I would make sure that debug is off, and that you have configured the cachePath for each extension.

from asset_compress.

leohidalgo avatar leohidalgo commented on May 14, 2024

markstory: it is my config file: http://pastebin.com/nMsfK018

my debug in the core.php is 0

the plugin is not writing anything in the directory

from asset_compress.

markstory avatar markstory commented on May 14, 2024

Does the webserver/owner of the process creating the files have permissions to write to the cache directory?

from asset_compress.

leohidalgo avatar leohidalgo commented on May 14, 2024

I have 777 permissions to directories

http://grab.by/crLg

from asset_compress.

markstory avatar markstory commented on May 14, 2024

I have no idea then. If you figure it out let me know if there is anything that needs to change in the plugin.

from asset_compress.

sesser avatar sesser commented on May 14, 2024

Maybe I'm missing something in the core of Cake, but if I move my webroot directory outside of the app directory, the WWW_ROOT constant is incorrect when running a Shell. My project looks like this:

project/
    - app
    - webroot

When running the AssetCompress Shell/Task, the WEBROOT 'token' in the config is replaced with project\app\webroot which in my case is incorrect and it's not finding any scripts/css to process.

How can I resolve this?

Thanks!

from asset_compress.

markstory avatar markstory commented on May 14, 2024

Don't move the webroot :) Alternatively, don't use WEBROOT, and use ROOT/webroot/ instead.

from asset_compress.

sesser avatar sesser commented on May 14, 2024

facepalm Oh, right. I saw that in the constantMap but didn't see it.

Thanks

from asset_compress.

sesser avatar sesser commented on May 14, 2024

One more thing I noticed:

ROOT/webroot/ccss/ => projectwebroot/ccss/

Untested, but the contantMap could use an extra slash on the replacement value:

array_walk($this->constantMap, function(&$path, $key) { $path = rtrim($path, DS) . DS; });

I just ended up using ROOT//webroot/ccss/ and that solved my problem.


UPDATE:

Seems there's a discrepancy in the way core contant paths are constructed. WWW_DIR and APP both have a trailing / where ROOT does not. Sorry, not really related to this plugin, but thought it should be known. The above array_walk in the constructor of AssetConfig should do the trick though.

from asset_compress.

markstory avatar markstory commented on May 14, 2024

I think an easy way to fix that would be to make the ROOT constant replacement just ROOT instead of ROOT/

from asset_compress.

sesser avatar sesser commented on May 14, 2024

Yep. It feels like this sort of token matching/replacing should be a unique token in the config. Something like {ROOT} or %ROOT% or whathaveyou... imagine if some poor sap actually had the name ROOT or APP in a file and/or path to a file. It would suck to be that poor sap. :)

I know, probably beyond the scope here, just more out loud thoughts.

Thanks for the fix!

from asset_compress.

duro avatar duro commented on May 14, 2024

I am running into the same issue that R0cKET was running into. I can get AssetCompress to combine my files, and I can even get it to store them in the cache folders when I run the shell. However when I put my app into production mode (Debug = 0) and access the app from the browser, I never get compiled files put into the cache folders, it just always regenerates them with each request and serves the controller rendered version.

Here is my config file: http://pastebin.com/Uj2BmmhQ

I have been trying to trace my way through the code of the plugin, and I see that it gets to Controller/AssetsController.php and executes the 'get' method. If I trace even further, it jumps into Lib/AssetCompiler.php and that generates the combined code. However at no point do I see Lib/AssetCache.php being referenced or utilized.

If I do the same tracing through Console/Command/AssetCompressShell.php I see that as soon as it jumps over to Console/Command/Task/AssetBuildTask and hits the '_generateFile' function it makes calls over to $this->Cacher.

My analysis so far seems to show that when generating through the Controller/AssetsController.php never even tries to cache the files.

Can someone let me know if I am missing something.

EDIT: Further digging shows that nothing in the code ever calls AssetCache->write() which is responsible for actually writing the cached files except the Console/Command/Task/AssetBuildTask. Is this the intention of the the plugin? Is is never supposed to write cached files unless the AssetBuild is done from the shell?

from asset_compress.

sesser avatar sesser commented on May 14, 2024

I was under the impression that AssetCompress wasn't called when debug=0. You have to generate the files before hand via the shell. Perhaps as part of the deployment process.

from asset_compress.

markstory avatar markstory commented on May 14, 2024

The controller never writes files to disk, this is intentional. If you need to generate static files use the shell.

from asset_compress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.