We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Can I have a library of private assets?

Is there a way to keep ones development assets private and then have the target path/uri public?

e.g.

$assets
  ->addJs('/app/assets/js/node/dev.object.js')
  ->addJs('/app/assets/js/node/dev.js')
  ->join(true)
  ->setTargetPath('/public/js/scripts.min.js')
  ->setTargetUri('js/scripts.min.js')
  ->addFilter(new Jsmin());


8.1k

Assets files must be in root directory of your server. Assets manager include link tags to head section. If you want use another files (not in the root directory), you can include these files directly to your views (using tag <script> or <style>). Like

<style>
<?php echo file_get_contents('/var/pecial/assets/css/norm.css'); ?>
</style>


1.6k

May I make a suggestion then that it be made possible to have private development assets and public filtered assets such as my example above.



8.1k

You can just use \Phalcon\Assets\Filters\Jsmin example

$script = 'alert("Test")';
$jsfilter = new \Phalcon\Assets\Filters\Jsmin();
echo $jsfilter->filter($script);

You can create special service, of course.



1.6k

I see, thank you.

I'll have to play around a bit to see if I can achieve my desired outcome.