1

My server with Joomla and API:

web/pruebasmario/joomla

web/public/api

I need use Jfactory..etc, functions plugin, componentes Joomla 2.5 in my Api.

I created a file accesjoomla.php in web/public/api:

<?php
include('../../pruebasmario/extjom.php');

$user = JFactory::getUser();
echo "Usuario " . $user->username . " con id: " . $user->id . " conectado a Joomla";  

I created a file extjom.php in web/pruebasmario/joomla:

/* Initialize Joomla framework */
  define( '_JEXEC', 1 );
  define('JPATH_BASE', dirname(__FILE__) );
  define( 'DS', DIRECTORY_SEPARATOR );
 /* Required Files */
 require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
 require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
 /* To use Joomla's Database Class */
 require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );

I look this: include Jfactory class in an external php file, Joomla Access Joomla 2.5 from external script to get article by id Joomla 2.5 Get User Data from External Script

BUT NO workk!!!!! :-((

Help me plez! thanks!

EDIT: I managed to take a step.

Adding: require_once (JPATH_BASE. DS. 'libraries'. DS. 'joomla'. DS. 'error'. DS. 'error.php');

I have no errors. But nothing appears. all white. The return of the api is not returned.

What is happening?

Community
  • 1
  • 1
daicon
  • 181
  • 3
  • 15
  • WHy are you using DS? Are you on a very very old PHP? Are you aware that it is not defined in Joomla 3? Are you asking how to bootstrap joomla? There are tons of examples of this. Why would you include the factory? http://developer.joomla.org/manual/ch01s02.html It's hard to understand what you are trying to do. – Elin Aug 04 '13 at 07:44
  • I use DS because file index.php of Joomla 2.5 use. My version php es new 4.x. I want to access from my API functions, the functions of Joomla, plugins, and componentes, no only Jfactory. – daicon Aug 04 '13 at 09:54
  • I try do http://developer.joomla.org/manual/ch01s02.html, but no work. I recive a screen White, without error. :-S – daicon Aug 04 '13 at 10:20
  • DS is deprecated in 2.5. It is gone in 3, so you should not be using it. I just got that link by googling and it worked fine for me. Have you gone to the developer site and read the manual and looked at the platform examples? Have you read about using JInput? Also please make it clear what you are trying to do. – Elin Aug 04 '13 at 12:32
  • I need to access joomla functions from outside the folder where joomla. I mean? I'm Spanish:-S .... Also, I removed the DS, and used '/', it works fine, but the error is the same....If you do not use DS, I have to use? – daicon Aug 04 '13 at 12:41
  • So are you asking how to bootstrap a stand along application? there are examples in the joomla-platform-examples reapository at github. TO get joomla outputs you just need to add a view.json.php file to the component you want to get data from. – Elin Aug 04 '13 at 12:45
  • No need outputs joomla, i need por example: Add new user from a script in folder different a joomla. Now i have this error: PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Library path /joomla2_5/joomla cannot be found.' in C:\xampp\htdocs\Joomla2_5\libraries\loader.php:251 Stack trace: #0 C:\xampp\htdocs\Joomla2_5\libraries\loader.php(279): JLoader::registerPrefix('J', '/joomla2_5/joom...') #1 C:\xampp\htdocs\script.php(16): JLoader::setup() #2 {main} thrown in C:\xampp\htdocs\Joomla2_5\libraries\loader.php on line 251 – daicon Aug 04 '13 at 12:55
  • i it solved. The problema is Jimport!!!! no work!! ¿Why? Requiere_once I have to use, and is very annoying. – daicon Aug 04 '13 at 20:29
  • It is completely impossile to tell without seeing code. – Elin Aug 04 '13 at 20:58

0 Answers0