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

Should load_plugins() only load plugin_name.php? #203

Closed
coofercat opened this issue Feb 3, 2015 · 4 comments
Closed

Should load_plugins() only load plugin_name.php? #203

coofercat opened this issue Feb 3, 2015 · 4 comments

Comments

@coofercat
Copy link

I'm writing a plugin, and have found that any .php files in the plugin directory get loaded (by include()). I realise this is a change to the way Pico loads plugins, but I don't think it should do this. I'd favour only loading one file (probably a .php file with the same name as the plugin, eg. plugins/my_plugin/my_plugin.php). That one file should then do any include() it needs on any other PHP files.

My primary motivation is that I'd like to use an external PHP library to provide me with some functionality in some cases. Having Pico load it for me means it has to be loaded on every page view, which adds to response time and memory requirement unnecessarily. If my plugin can load it when required, then it only affects the page views that need it.

If this idea sounds useful/sensible/helpful, I'll produce a patch/pull request for it (all the fun is in the load_plugins() method, line 115 or so).

@mistergraphx
Copy link

i've done this with a plugin.yaml description file im my case only the plugin with this file are loaded.

here is my modified function if it can help :

/**
     * Load plugins
     *
     * a plugin is minimaly described by a name in a plugin.yaml config file
     * and a class/file . name, class and file must be identicals
     *
     * 
     *
     * @todo each web site must load only site.config activated plugins
     */
    protected function load_plugins() {

        $this->plugins = array();

                $yamlFiles = $this->get_files(PLUGINS_DIR, 'plugin.yaml');

                if(!empty($yamlFiles)){
                    foreach($yamlFiles as $file){
                        $plugin =Yaml::parse(file_get_contents($file));
                        $plugin['path'] = str_replace('plugin.yaml','', $file);
                        $php_file = $plugin['path'].$plugin['name'].'.php';

                        include_once($php_file);
                        if(class_exists($plugin['name'])){
                            $obj = new $plugin['name'];
                            $this->plugins[] = $obj;
            }
                    }
                }
    }


Look how many pull-request are waiting , there is an issue about a new maintainer or active team for Pico. Nobody 'll never pull anything ...

@PhrozenByte
Copy link
Collaborator

Ideas about how to achieve this in a backwards-compatible manner are appreciated! I though about this with Pico 1.0/#252 too, but didn't found a satisfying solution. Please also note that we don't want to increase complexity (at least not considerable; "stupidly simple").

@PhrozenByte
Copy link
Collaborator

PhrozenByte commented Sep 4, 2016

We'll very likely implement this with Pico 2.0, see #317.

@PhrozenByte PhrozenByte modified the milestones: Version 2.0.0, Backlog Sep 4, 2016
@PhrozenByte PhrozenByte reopened this Sep 4, 2016
@PhrozenByte PhrozenByte mentioned this issue Dec 5, 2016
41 tasks
@PhrozenByte PhrozenByte modified the milestones: Version 2.0.0, Version 3.0.0 Dec 12, 2016
@PhrozenByte
Copy link
Collaborator

This feature will be shipped with Pico 2.0, see 9254240 for implementation details. For feedback about this feature, please refer to #334. Thank you for bringing this up!

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

No branches or pull requests

4 participants