Stolz / Assets

An ultra-simple-to-use assets management library for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why don't use full URLs intead of relatives?

f-liva opened this issue · comments

I always have a lot of problem configuring this library due it generate relative URLs instead of full ones.

Why don't add an option to set if Stolz will generate relative or full urls?

commented

Well, the library generates the kind of URLs you give to it. If you give relative URLs, it will generate relative URLs and if you give absolute URLs, you'll get absolute URL.

The default configuration is for using relative URLs but it can be changed. Why default to relative URLs configuration?

  • To save space and take advantage of hierarchical locality.
  • To avoid nightmares when deploying to multiple environment.
  • And for a ton more of reasons every web programmer with experience should be aware of.

If you want to to use absolute URLs by default you have plenty of options:

  • Always provide absolute URLs.

  • Include your base URL in the css_dir and js_dir configuration options:

    // config.php
    'css_dir' => 'http://mydomain.com/css',
    'js_dir' => 'http://mydomain.com/js',

  • Set use the <base> HTML tag pointing to your root base absolute URL.

  • Use the closure feature of the css and js functions to convert the URLs to your needs

If you have problems configuring and using the relative links, here are two good documents to read:

When I declare css_dir and js_dir as an url, I get this error:

ErrorException in Manager.php line 464:
mkdir(): Invalid argument (View: D:\Progetti\studioelps.com\StudioElps\resources\views\master.blade.php) (View: D:\Progetti\studioelps.com\StudioElps\resources\views\master.blade.php)

Using absolute URLs work, but causes a mkdir error when pipeline is enabled

commented

@fede91it , sorry for the late response.

I forgot the pipeline uses 'css_dir' and 'js_dir' for creating the dir. Then I'm afraid if you want to default to absolute URL you need to use one of the above approaches.

Ok thanks, I'll send you a PR for this issue asap