tattersoftware / codeigniter4-assets

Asset handling for CodeIgniter 4
MIT License
50 stars 12 forks source link

Create UrlHandler.php #23

Closed evansharp closed 3 years ago

evansharp commented 3 years ago

Looking at #14 ....

If I understand the gathering of resources correctly, I think this will allow a url to be used instead of a path in both config and manifest config routes.

Looks like non-directory strings are just dropped by the other handlers, so I think this new handler will just enable the additional functionality.

Will add documentation to Readme if accepted.

evansharp commented 3 years ago

Oh wait, this might choke the publish command because it assumes a local path input. I'll need to read the manifest service to see what can be done to passover a url string.

evansharp commented 3 years ago

... nevermind, I see now that publish only looks at manifests, which leaves configured route values to be anything they want to be.

MGatner commented 3 years ago

Paths are all assumed to be local files. #14 is referring to a method of harvesting CDN files (via Manifests) to make them local files.

Your PR does raise a valid point though: how about people who want remote assets but want to handle them with this library so they are all in one place? I think it will take some larger changes than just a new handler, but that is a start.

evansharp commented 3 years ago

To be fair, I haven't tried this out yet. I have a large project in solo development that is at the stage where I need to start optimizing the asset loading with conditionality; which is what brought me to check on the evolving ci4 library landscape.

I think given the potential to be exactly what I need, I'm going to go ahead and refactor my project to make use of this library and try my approach out there. I agree it seems too simple to just add a handler, but if it does work out to add the minor funcyionality, I'm not going to complain.

Can you offer insight into the likelihood that an asset manger makes it into ci4 core? Maybe at 4.1?

MGatner commented 3 years ago

I think an asset manager is probably unlikely. What I was referring to is that I would like to see a "Publisher" component in the core: some centralized means for moving files into the served space (i.e. public/). This is a much broader scenario but would help a lot with assets.

evansharp commented 3 years ago

In that case, are you interested in me continuing to PR on this library?

MGatner commented 3 years ago

I would love your ideas and additions! Any new features added can be released now without a major version. Anything that gets refactored out of the library will be used somewhere else, so nothing will be wasted. But I also understand if you would rather wait for the "dust to settle" given the big upcoming changes.

evansharp commented 3 years ago

if you would rather wait for the "dust to settle"

yes.

Can I just leave this open to remind me though?

MGatner commented 3 years ago

This has been incorporated into the framework via Publisher, which will become the basis for the new version of Assets's publishing: https://github.com/codeigniter4/CodeIgniter4/blob/5a6f664a29a929fb8ea991fd118ba69664422cbb/system/Publisher/Publisher.php#L332-L348