ekandreas / bladerunner

WordPress plugin for Laravel Blade templating DEPRECATED
http://bladerunner.elseif.se
12 stars 1 forks source link

[Question] How to run not as a plugin? #78

Closed OwenMelbz closed 3 years ago

OwenMelbz commented 6 years ago

Hey,

Came across your package today, and it seems to do pretty much exactly what we're after,

However we don't really like the idea of having an "optional" plugin - which is required by a theme - e.g if they disable the plugin, the theme will break.

As there is a direct relationship between bladerunner and the theme, it seems sensible to able to almost force the bladerunner dependency behind the scenes.

--

So is it possible to load your package, e.g within a theme functions.php via something like new Ekandreas\Bladerunner instead of having to load a whole plugin for it?

The reason we noticed this is because all our packages are fully loaded through composer, so having 1 package randomly loading as a plugin seems weird?

--

Thanks, and much appreciate time and effort you've put into this project!

ekandreas commented 6 years ago

Yes, I understand your point of view. I share it. It is a plugin because we need some basic integration points (hooks/filters) with WP. You can place it as a mu-plugin if you want. Or perhaps use philo/laravel-blade which is much lighter (no controllers, etc). It would be nice to use Bladerunner as a vendor package and make the hooks manually in theme code. But for now it is not possible.

OwenMelbz commented 6 years ago

I've been having a look around, and I see the problem for more vanilla wordpress installs.

Although I had a little play around, and reduced the overhead to

add_action('after_setup_theme', function () {
    new Ekandreas\BladerunnerLoader;
});

the new BladerunnerLoader class basically does the

public function __construct() {
    array_map(function ($file) {
        $file = "globals/{$file}.php";
        require_once($file);
    }, ['helpers', 'setup', 'filters']);
}

Would be interesting to see how easy it will be to provide a maintainable alternative loading mechanism.

ekandreas commented 6 years ago

Great! Place a filter to the plugin loader? Perhaps a PR? :-) Great!

OwenMelbz commented 6 years ago

Well at the moment it completely breaks traditional wordpress installs :D so no where near PR ready lol

If I can see a way to make it work with both, without having to and 2 code-bases then i'll try get one going

vpillinger commented 6 years ago

Maybe I am missing something here. But I was able to put the blade-runner folder in my theme and reference it via require_once __DIR__ . '/bladerunner/bladerunner.php'; at the top of my functions file. Everything appeared to keep working properly.

The only additional step that I needed to do was run 'composer update' in the blade-runner folder, but this is a normal installation step anyway.

What is the exact issue that was prevent anyone from doing this before? I am guessing that there is some minor performance loss or something similar because everything keeps getting reinitialized on every load?

ekandreas commented 3 years ago

Hi! This is a deprecated package. Please use https://github.com/EFTEC/BladeOne instead!