Closed radmen closed 7 years ago
IMO, it's not paramount ATM, but it's definitely something that we have to consider.
I can take care of it unless someone else wants to tackle this. I can assign it to myself and get it done for v0.1
I think, that there's no need to do it now. If we want to compile everything into single file I can prepare engine for that.
Cool, thanks.
I'll assign this task to both of use, and label it 'Enhancement' for the 1.0 release.
so - should I prepare a single file compiler, or do you have something else in mind?
I haven't researched it, yet. Single file would definitely work, it easily be done with a shell script or Gulp.
Do you have something ready that you've used in the past?
Do you have something ready that you've used in the past?
Not something that would suit our needs. I'm also not so sure about simple concatenation of files (I've fought about "extraction" of functions to a single file), but I need to check it.
Like mentioned in #105, I'm taking care of file concatenation to avoid too many requires in one file (as well as having to add one manually every time).
Honestly, I though it would work by adding something similar to this Composer script, but it doesn't:
"concat": "php -r \"array_map(function($dir) { file_put_contents('dist/zubr.php', file_get_contents($dir, LOCK_EX)); }, glob('src/*.php'));\""
I'm not amazingly familiar with these kinds of tasks directly in Composer, I'll try to figure some out tomorrow when I'm more rested.
The problem with the above is that I can't seem to be able to set the document root correctly (at least on my machine). I guess it would be easier to just create a built.php
file, which is probably what I'll try next. I couldn't find anything on Packagist right now, and I don't think we should introduce Gulp as it would bring Node in as a requirements, which might not be ideal.
I've added a simple PHP-based build script: https://github.com/nkkollaw/zubr/pull/109
Feedback and contributions welcome. If everything looks good I'll merge.
I've read comment on Reddit regarding
require_once
bottleneck.While it's not important ATM we can think about how it should be solved.
My suggestion - write a script which compiles all functions defined in
Zubr
namespace and create a single file with all definitions.It's not an ideal solution - it requires creating a new bundle every time when something changes so it can be error prone.
This could be prevented by creating git hook which checks if new bundle has to be compiled. Again, quite an inconvenience.
What do you think about it?