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

Autoload static files without copy/paste #3

Merged
merged 4 commits into from
Jan 9, 2016

Conversation

snapshotpl
Copy link
Member

This pr make installation simple as possible and make middleware ready to use out-of-box. Solution for #2

}

$staticResponse = new Response();
$staticResponse->getBody()->write(file_get_contents($fullPathToFile));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better: create a new stream instance and pass it to the response on creation. When creating the stream instance, give it the path to the file:

$stream = new Stream($fullPathToFile, 'r');
$staticResponse = new Response($stream);

That way you don't have any memory overhead from reading the file, and keep I/O down to a minimum.

@weierophinney
Copy link
Contributor

I like it! Let me know when you've merged and tagged, and I'll update the expressive docs (as I have detailed the copy + baseUrl method currently).

@snapshotpl
Copy link
Member Author

Thanks for advice! I will merge it tomorrow.

snapshotpl added a commit that referenced this pull request Jan 9, 2016
Autoload static files without copy/paste
@snapshotpl snapshotpl merged commit e9b7f6d into master Jan 9, 2016
@snapshotpl snapshotpl deleted the autoload-static-files branch November 14, 2016 08:23
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

Successfully merging this pull request may close these issues.

2 participants