[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jfw] Re: Joomla "Framework" today and what we called Joomla Framework in the past



Hi Louis,

Happy to help, will start from your last question first.

What is the Joomla Framework

Most of the information about the Joomla Framework is not valid anymore, and the information on http://framework.joomla.org would better be removed to avoid further confusion among developers. 

At present the code found at https://github.com/joomla-framework provides a set of PHP libraries that are slowly being adapted by the Joomla core, some are already in latest version of Joomla, others are more modern replacements for Joomla core libraries.

If you look at it in that context the name "Joomla Framework" still means the PHP libraries that are part of the Joomla core, of which some are available standalone through: https://github.com/joomla-framework

How to integrate with Joomla through an external script

As far as I know there is not package or library in http://github.com/joomla-framework that makes it easier to integrate with an existing Joomla installation. There is a revised Application package, but this doesn't help much for the existing Joomla core.

This brings you the following 3 options:

1. Boot the Joomla Cms
2. Use Joomla classes directly
3. Don't use any Joomla code

1. The best and safest solution to integrate with Joomla externally is to boot the Joomla Cms application. This way you are sure all the dependencies are properly loaded and everything works as it should be. 

An example if our Joomlatools Console application bootstrapper. This is used by the console to bootstrap Joomla as a CLI application and allows you to use it from the CLI. It handles dependencies and bootstrapping for you. (Similar to the links you listed but for latest version of Joomla)

Code: https://github.com/joomlatools/joomlatools-console/blob/master/src/Joomlatools/Console/Joomla/Application.php

2. You could also choose an approach to use specific classes directly. This will quickly fail if you start to integrate with components, it will work if you need to call very specific API's that are uncoupled. However, there is a lot of coupling in the core to be able to do this safely.It might work if for example you only need the database layer, without any other dependencies. 

3. In case you do not need to integrate with any of the Joomla classes or API's, for example as in your case you wish to merge to database tables you would decide to just use an external script that is completely custom, either written from scratch or using another framework or choice to help you. 

About your problem

"Right now, I'm writing a custom script to merge the users table of two Joomla installations (it has to be very specific, to deal with duplicates and fill an other table, etc).  For the creation of users, I thought about using the above method."

This problem is a great fit for our Joomlatools Console. You could create a console plugin that can merge two user tables and also have the ability to create new users. Commands could be

joomla users:merge
joomla users:create
joomla users:remove

etc.

Information about the console you can find here: https://www.joomlatools.com/developer/tools/console/ and a complete tutorial on how to create custom plugins and publish them on Packagist you can find here: https://www.joomlatools.com/developer/tools/console/plugins/

If you have any more questions let me know!

Happy coding!

Johan

On Sunday, August 7, 2016 at 12:36:02 PM UTC+2, Louis-Sébastien Gac-Artigas wrote:
Main Question of this post : Does the new Joomla Framework give a good way to interact with a Joomla CMS Installation from an external script ?

In the old times, we used the term "Joomla Framework" to speak about the "Joomla CMS Core"
For example, if someone wanted to load the Joomla CMS "framework" (core) from an external script, it was usual to do:


define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
define( 'DS', DIRECTORY_SEPARATOR );
 
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
 
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();

(in both of those tutorials, they say Joomla "Framework")

First questions:

Right now, I'm writing a custom script to merge the users table of two Joomla installations (it has to be very specific, to deal with duplicates and fill an other table, etc). 
For the creation of users, I thought about using the above method.

Is that approach still ok with Joomla 3, or should I use the new "Joomla Framework"? 
Does the new Joomla Framework give a good way to interact with a Joomla Installation from an external script ?


Secondary question:
Knowing that by the past many people used to google "Joomla Framework" to find how to load the Joomla CMS core, maybe few lines explaining the difference between what is called "Joomla Framework" today and what was called "Joomla Framework" in the past could be usefull in https://framework.joomla.org/ ?

--
Framework source code: https://github.com/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-framework.