MyBB Community Forums

Full Version: 1.8 Plugins Compatible With 2.0 PLZ
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
(2015-08-03, 06:26 AM)Euan T Wrote: [ -> ]It'll still be possible to create plugins with a single file.

Yes and it will also be possible to create plugins with a nice structure too Wink
(2015-08-03, 06:47 AM)martec Wrote: [ -> ]
(2015-08-03, 06:26 AM)Euan T Wrote: [ -> ]It'll still be possible to create plugins with a single file, no idea where you got that from. We're still using a system like the hooks system, just cleaning it up and improving it (eg: multiple parameters for hook functions).

I think because of mybb 2.0 using framework need several files to create extension...
Too something like controller, routing for me only complicate than simplifcate... if not need controller or something like so ok...

You can do it like that, or if it's a simple plugin you can simply use hooks. The only requirement is a main plugin class, which returns the plugins details and initializes any hooks. Other than that, developers are free to write their code as they wish.
(2015-08-03, 11:43 AM)Euan T Wrote: [ -> ]You can do it like that, or if it's a simple plugin you can simply use hooks. The only requirement is a main plugin class, which returns the plugins details and initializes any hooks. Other than that, developers are free to write their code as they wish.

so need put something like $plugins->add_hook('global_start', 'xxxxxxxx');  inside of class ?

what will change something like below (very very simple plugin)?

$plugins->add_hook("global_start", "rot");
function rot () {
global $rand;

$rand = mt_rand("1","16");

}

only will need change that i need put $plugins->add_hook("global_start", "rot"); inside of class? or something above not will work?
We haven't yet built the extensions system for 2.0 so we cannot give specific implementation details at this time, anything we could say would only be classed as speculation and should not be taken as a contract or concrete decision.
So it seems that will not be as simple as system 1.x then.
I understand that should add more feature like modifying existing function, more control over template etc.
But just hope it does not get that confused and laborious thing to make a simple plugin like in phpbb.
I understand that to make a complex plugin can be simpler with something more powerful, but to make simple thing looks like it will become more complicated.
(2015-08-03, 02:35 PM)martec Wrote: [ -> ]So it seems that will not be as simple as system 1.x then.
I understand that should add more feature like modifying existing function, more control over template etc.
But just hope it does not get that confused and laborious thing to make a simple plugin like in phpbb.
I understand that to make a complex plugin can be simpler with something more powerful, but to make simple thing looks like it will become more complicated.

You're putting words in my mouth. Please stop it.

Our aim will be to make it as simple or complex as required to develop extensions. If your extension just needs a few closures for some hooks then that should be possible and equally if you need the power of an MVC framework then that should also be possible. The complexity should be flexible.

But we are not in a position to give guarantees or specific implementation details at this time.
(2015-08-03, 02:20 PM)martec Wrote: [ -> ]
(2015-08-03, 11:43 AM)Euan T Wrote: [ -> ]You can do it like that, or if it's a simple plugin you can simply use hooks. The only requirement is a main plugin class, which returns the plugins details and initializes any hooks. Other than that, developers are free to write their code as they wish.

so need put something like $plugins->add_hook('global_start', 'xxxxxxxx');  inside of class ?

what will change something like below (very very simple plugin)?

$plugins->add_hook("global_start", "rot");
function rot () {
global $rand;

$rand = mt_rand("1","16");

}

only will need change that i need put $plugins->add_hook("global_start", "rot"); inside of class? or something above not will work?

It'll be more like:

class MyPlugin extends \Mybb\Core\AbstractPlugin
{
    public static function getInfo()
    {
        return [
            'name' => 'My Plugin',
            'description' => 'My plugins description...',
            // etc.
        ];
    }

    public function register()
    {
        $this->events->on('global_start', function() {
            global $rand;

            $rand = mt_rand("1","16");
        });
    }
}

This leads to much better code, encapsulates your variables to prevent conflicts between plugins and makes it far easier to trace what is happening where.

As Will said, we have not yet implemented the plugin system, but when we have we will be releasing a full blog post and documentation describing how to implement both simple and more complex plugins with full code samples.
I'm sorry for anything.
It's just fear.
When I saw the phpbb extension system made me quite scared.
(2015-08-03, 03:05 PM)martec Wrote: [ -> ]I'm sorry for anything.
It's just fear.
When I saw the phpbb extension system made me quite scared.

We're still trying to keep it as simple as we can as we believe the best part about MyBB is how easy it is to customize. At the same time, we also want to make it powerful and modern, which is why we're taking the approach we are Smile

As said, there will be a full set of documentation and examples made available at the same time as the first Alpha release. We'll also be taking community submissions to the documentation (as we do now) and examples to make it as easy as possible to start writing extensions and themes.
(2015-08-03, 03:02 PM)Euan T Wrote: [ -> ]It'll be more like:

class MyPlugin extends \Mybb\Core\AbstractPlugin
{
    public static function getInfo()
    {
        return [
            'name' => 'My Plugin',
            'description' => 'My plugins description...',
            // etc.
        ];
    }

    public function register()
    {
        $this->events->on('global_start', function() {
            global $rand;

            $rand = mt_rand("1","16");
        });
    }
}

This leads to much better code, encapsulates your variables to prevent conflicts between plugins and makes it far easier to trace what is happening where.

As Will said, we have not yet implemented the plugin system, but when we have we will be releasing a full blog post and documentation describing how to implement both simple and more complex plugins with full code samples.

thanks for example.
It is acceptable. Even personally classes and obeject not be as familiar.

(2015-08-03, 03:10 PM)Euan T Wrote: [ -> ]
(2015-08-03, 03:05 PM)martec Wrote: [ -> ]I'm sorry for anything.
It's just fear.
When I saw the phpbb extension system made me quite scared.

We're still trying to keep it as simple as we can as we believe the best part about MyBB is how easy it is to customize. At the same time, we also want to make it powerful and modern, which is why we're taking the approach we are Smile

As said, there will be a full set of documentation and examples made available at the same time as the first Alpha release. We'll also be taking community submissions to the documentation (as we do now) and examples to make it as easy as possible to start writing extensions and themes.

Great to hear that.
This will help a lot of people in the conversion of plugins to 2.0.
Pages: 1 2 3