Open younes0 opened 12 years ago
This is perfectly possible using Casset, as is. Your config would look something like this:
// In config/casset.php
<?php
return array(
...
'paths' => array(
'core' => 'assets/', // All assets in the 'core' namespace (default) are located in public/assets/
),
...
'js_dir' => 'javascripts/', // Javascript files are located in <namespace>/javascripts/, so public/assets/javascripts/ by default
...
'groups' => array(
'js' => array(
'main' => array( // 'main' group
'files' => array(
'bootstrap.js', // Add public/assets/javascripts/bootstrap.js
'jquery/*.js', // Add public/assets/javascripts/jquery/*.js
'application/common/*.js', // Add public/assets/javascripts/application/common/*.js
),
),
),
),
)
Does that make sense? Does that solve the problem you're having?
Thanks it worked!
However I encountered a problem with the assets folder beeing outside (and not in public) Settings 'core' to '..\assets\' or to the full path 'C:\www\myapp\assets\' didn't work so I removed the DOCROOT references in the Casset Class as a temporary fix...
Aha interesting. In my own testing, settings 'core' to ../assets/
or ..\\assets\\
worked fine. Did you forget to escape your backslashes?
Since my application doesn't follow the FuelPHP structure (the Core is located in \vendor\fuelphp), it may have caused some errors with Casset. I noticed in the errors that if I set an absolute path, the DOCROOT is prefixed.A relative path: DOCROOT is not fixed. It's all about DOCROOT anyway.
Yeah, I should probably be using realpath()
instead. I'll look into it.
Do you mind if I ask you a couple more questions about your current setup, as a relative path should be working?
If core is in \vendor\fuelphp, what is DOCROOT set to? Where is your public\ folder? (This should be the same as DOCROOT). Where is your assets\ folder?
DOCROOT is myapp\ myapp\public (switching it as docroot does not solve the problem) myapp\assets myapp\vendor\packages\casset myapp\vendor\fuelphp\core
I'm not using the Router/Request classes, so the Uri class is useless (but you don't use it apparently). IMHO maybe it's not worth to fix my problem since I didn't setup Fuelphp as recommended.
Interesting. My code does assume that DOCROOT == the public folder == the script's CWD (a bad assumption, which I will change). But setting DOCROOT = the public folder, and setting 'core' => '../assets/'
should, in theory, work.
I made some tests again: it seems that I didn't switch the public folder as the DOCROOT sorry. Everything works fine. Thank you so much for your help.
Aha, thanks for re-trying!
You raise a valid point though: I assume that DOCROOT is the public folder, and I don't allow absolute paths for 'core'. I'll address both of these soon. Thanks for your input!
I'm re-opening this to remind myelf to address the above issues at some point
I'm new to FuelPHP and I used my own assets library before that. In a similar way to Casset, I had groups and files to define. The problem is I can't manage to setup Casset as easily because of the files array.
Here's what I would have set for my library :
Can this be applied in Casset OR would be a nice feature to be implemented ?