Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serving media files from within a vendor directory? #6

Open
samwilson opened this issue Sep 2, 2013 · 4 comments
Open

Serving media files from within a vendor directory? #6

samwilson opened this issue Sep 2, 2013 · 4 comments

Comments

@samwilson
Copy link

How would you recommend one go about serving media files (css, js, and images) from within a vendor directory? Specifically, I've got vendor at the top level (DOCROOT), where it's installed by Composer. I've got a hack working with the following in the Media controller:

    if ( ! $cfs_file)
    {
        echo $cfs_file = DOCROOT.'vendor'.DIRECTORY_SEPARATOR.$filepath;
    }

but that does seem pretty hacky. Any suggestions?

Thanks! :-)

@zeelot
Copy link
Owner

zeelot commented Sep 2, 2013

Hmm, the module was specifically meant to work with the cascading filesystem, but maybe we can improve this. Can you give me an example of a composer package that adds media files and how the url might look like? Where does the vendor library keep the files?

@samwilson
Copy link
Author

Good point. There really isn't any convention in composer libraries about where they keep their web-accessible media files, unfortunately.

Maybe there's a better way. It is actually easy to set up the project's composer.json to put the vendor directory into Kohana's APPPATH (by using "vendor-dir": "application/vendor"), so does that make it easier to keep it within the CFS?

At the moment, media files are located with

$cfs_file = Kohana::find_file('media', $filepath, FALSE);

so perhaps this could be followed by

if ( ! $cfs_file)
{
    $cfs_file = Kohana::find_file('vendor', $filepath, FALSE);
}

Although, that's a bit hacky too, considering that find_file() is a thing that's meant to iterate over the permitted locations and return the first matched file. Hmmm... I'm not sure.

What do you think?

@zeelot
Copy link
Owner

zeelot commented Sep 3, 2013

It should probably be a different route and action, can you give me an example of a composer package with media files and where they end up?

@samwilson
Copy link
Author

Here're are a couple:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants