themosis / framework

The Themosis framework core.
https://framework.themosis.com/
GNU General Public License v2.0
671 stars 121 forks source link

Feature Request - Separate framework for plugin only development #75

Closed mordant23 closed 9 years ago

mordant23 commented 9 years ago

We use WordPress multisite for a variety of websites. I really love the promise of Themosis framework but it doesn't seem that it can be used for development of just a plugin or just a theme. We prefer to keep most of our functionality within plugins which can be loaded as needed for a variety of sites on a multisite instance. It appears that the Themosis framework is meant to be used for a stand alone site with most of the functionality, which should be in a plugin, developed in the theme.

Ideally we'd like to use a framework such as Themosis for both stand alone plugin development as well as for stand alone theme development. Is there a way to currently modify Themosis framework for this use case?

jlambe commented 9 years ago

This feature is one of the most asked: be able to develop plugin that are using the framework apis. Technically you could already make it in fact. You can develop a plugin and boostrap it only at the themosis_bootstrap action hook like so:

<?php
/**
 * Plugin Name: Your plugin name
*/
// Wait the core framework classes are loaded.
add_action('themosis_bootstrap', function()
{
    // Your plugin code.
});

This is not yet tested but in theory you could get access to the core API but you'll need to import the classes on your files or use their full class name. For example, a custom post type:

\Themosis\Facades\PostType::make();

If you have time to test, let me know how it goes. But this feature is on the roadmap ;) You can subscribe on the newsletter or follow us on Twitter for updates regarding new versions of the framework. Hope this helps.

mordant23 commented 9 years ago

Thank you for the quick response. I'll let you know what happens when I test it. WordPress is a growing part of our company and I want to lead us to using it per the best practices of PHP. I'm really looking for something that will enforce MVC architecture while cutting down development time. This looks the best option out there.

mordant23 commented 9 years ago

I was able to use the simple example to create a custom post type, so that works. The real advantage I would want with using the Themosis framework for a plugin is the ability to enforce the mvc architecture on my developers. It would be nice to have a similar file structure as /app in the plugin folder.

In other words, I would load the Themosis plugin and the plugin we would write would have an "app" directory which acts similarly to the "app" directory in the theme. I haven't yet been able to figure out how to do that. If I read the code correctly, the assumption is that the app folder is in theme directory and a lot of the path setting functions use the get_template_directory_uri() or other functions that are dependent on finding the theme path.

jlambe commented 9 years ago

That's one great news. Yes I'm thinking about giving a file structure for plugin development as well. But as you mentioned, we need to find a way to easily manage the paths and uri to some of the files so everything can work smoothly.

mordant23 commented 9 years ago

Thank you. I look forward to the development. In the meantime I'll fork the repository and see what I can do on my end. If I come up with something substantial I'll put in a pull request.

mithublue commented 9 years ago

@mordant23 : i have tried using this framework to develop the plugin, as u said you have made post type with it. will u please share the copy of the framework u are using and the code used to make the post type, please so i can have the idea of workflow?