debugging php json backend

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

debugging php json backend

Farid Elyahyaoui-2
Hi y'all,

I'm steadily forwarding with my project that uses qooxdoo and the php
backend. And I must say that qooxdoo rocks!
It already contains a few thousand lines of source code, of which many
in the backend.
It uses classes as in the demo backend from the qooxdoo project.
Debugging has been cumbersome using print statements in the php file and
looking in the apache/php error files of my webserver to see what
happened. For some reason the errors in the methods of the classes don't
generate errors in the error-log files so I always used print statements.
Now I have a problem which I can't solve this way.

I'm trying to integrate the new joomla 1.5 framework (see
http://forum.joomla.org/viewtopic.php?f=304&p=1332208) but there is an
error when I include the joomla framework file:
--------------------------------
....
//joomla stuff
define( '_JEXEC', 1 );
define('JPATH_BASE', '/var/www/vhosts/noobizz.com/httpdocs/joomla' );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );<---FAILS!

$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$mainframe->route();
$juser =& JFactory::getUser();

class class_general
{
     function method_loadUser($params, $error)
     {
       $json=new JSON();
       return $json->encode($juser );
     }
}
-------------------
If I add the line that says "FAILS", nothing works, but I don't get an
error message in the log files (as with all errors in my class methods).
without this line of course the rest of the file will fail.
the strange thing is if I make a php file with these lines without the
class and methods (but just the includes and joomla stuff) it works
properly:
<?php
define( '_JEXEC', 1 );
define('JPATH_BASE', '/var/www/vhosts/noobizz.com/httpdocs/joomla' );
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();

$mainframe->route();
$user =& JFactory::getUser();

print_r($user);

echo "dit was het dan";
?>


my questions:
-why are the errors not written to the error log files?
-why does it work in the last example but not in the qooxdoo php backend?
-Any people out there that have a way to use the php backend and get
proper error messaging?
-How do you guys/girls debug your php backend?
-Did anybody use qooxdoo php backend with the Joomla framework?

thanks in advance.

Farid


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: debugging php json backend

Farid Elyahyaoui-2
I know a bit more now.
I stripped the php file to the bare minimum and in the error log I now
see the line:
------------
[client 86.86.79.205] PHP Notice:  Undefined variable:
serviceComponents in
/var/www/vhosts/noobizz.com/httpdocs/services/index.php on line 378,
referer:
http://noobizz.com/qooxdoo/0.7.2/qooxdoo-0.7.2-skeleton/helloworld/source/view.php
---------------

line 378 in index.php from the standard php backend says:

$className = "class_" . $serviceComponents[count($serviceComponents) -1];

but on line 346 the variable $serviceComponents is already defined:

$serviceComponents = explode(".", $jsonInput->service);

what could be the cause that on line 378 $serviceComponents is not known?
as said this only happens if I include the framework.php file.

Farid



farid schreef:

> Hi y'all,
>
> I'm steadily forwarding with my project that uses qooxdoo and the php
> backend. And I must say that qooxdoo rocks!
> It already contains a few thousand lines of source code, of which many
> in the backend.
> It uses classes as in the demo backend from the qooxdoo project.
> Debugging has been cumbersome using print statements in the php file and
> looking in the apache/php error files of my webserver to see what
> happened. For some reason the errors in the methods of the classes don't
> generate errors in the error-log files so I always used print statements.
> Now I have a problem which I can't solve this way.
>
> I'm trying to integrate the new joomla 1.5 framework (see
> http://forum.joomla.org/viewtopic.php?f=304&p=1332208) but there is an
> error when I include the joomla framework file:
> --------------------------------
> ....
> //joomla stuff
> define( '_JEXEC', 1 );
> define('JPATH_BASE', '/var/www/vhosts/noobizz.com/httpdocs/joomla' );
> define( 'DS', DIRECTORY_SEPARATOR );
> require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
> require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );<---FAILS!
>
> $mainframe =& JFactory::getApplication('site');
> $mainframe->initialise();
> $mainframe->route();
> $juser =& JFactory::getUser();
>
> class class_general
> {
>      function method_loadUser($params, $error)
>      {
>        $json=new JSON();
>        return $json->encode($juser );
>      }
> }
> -------------------
> If I add the line that says "FAILS", nothing works, but I don't get an
> error message in the log files (as with all errors in my class methods).
> without this line of course the rest of the file will fail.
> the strange thing is if I make a php file with these lines without the
> class and methods (but just the includes and joomla stuff) it works
> properly:
> <?php
> define( '_JEXEC', 1 );
> define('JPATH_BASE', '/var/www/vhosts/noobizz.com/httpdocs/joomla' );
> 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();
>
> $mainframe->route();
> $user =& JFactory::getUser();
>
> print_r($user);
>
> echo "dit was het dan";
> ?>
>
>
> my questions:
> -why are the errors not written to the error log files?
> -why does it work in the last example but not in the qooxdoo php backend?
> -Any people out there that have a way to use the php backend and get
> proper error messaging?
> -How do you guys/girls debug your php backend?
> -Did anybody use qooxdoo php backend with the Joomla framework?
>
> thanks in advance.
>
> Farid
>
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: debugging php json backend

Alexander Back
Hi Farid,

I'm no PHP expert, but do you have already searched for this variable
name in the framework.php file? Maybe this file also uses this variable
name and things get mixed up.

Just a guess ...

cheers,
   Alex

farid wrote:

> I know a bit more now.
> I stripped the php file to the bare minimum and in the error log I now
> see the line:
> ------------
> [client 86.86.79.205] PHP Notice:  Undefined variable:
> serviceComponents in
> /var/www/vhosts/noobizz.com/httpdocs/services/index.php on line 378,
> referer:
> http://noobizz.com/qooxdoo/0.7.2/qooxdoo-0.7.2-skeleton/helloworld/source/view.php
> ---------------
>
> line 378 in index.php from the standard php backend says:
>
> $className = "class_" . $serviceComponents[count($serviceComponents) -1];
>
> but on line 346 the variable $serviceComponents is already defined:
>
> $serviceComponents = explode(".", $jsonInput->service);
>
> what could be the cause that on line 378 $serviceComponents is not known?
> as said this only happens if I include the framework.php file.
>
> Farid
>
>
>
> farid schreef:
>> Hi y'all,
>>
>> I'm steadily forwarding with my project that uses qooxdoo and the php
>> backend. And I must say that qooxdoo rocks!
>> It already contains a few thousand lines of source code, of which many
>> in the backend.
>> It uses classes as in the demo backend from the qooxdoo project.
>> Debugging has been cumbersome using print statements in the php file and
>> looking in the apache/php error files of my webserver to see what
>> happened. For some reason the errors in the methods of the classes don't
>> generate errors in the error-log files so I always used print statements.
>> Now I have a problem which I can't solve this way.
>>
>> I'm trying to integrate the new joomla 1.5 framework (see
>> http://forum.joomla.org/viewtopic.php?f=304&p=1332208) but there is an
>> error when I include the joomla framework file:
>> --------------------------------
>> ....
>> //joomla stuff
>> define( '_JEXEC', 1 );
>> define('JPATH_BASE', '/var/www/vhosts/noobizz.com/httpdocs/joomla' );
>> define( 'DS', DIRECTORY_SEPARATOR );
>> require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
>> require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );<---FAILS!
>>
>> $mainframe =& JFactory::getApplication('site');
>> $mainframe->initialise();
>> $mainframe->route();
>> $juser =& JFactory::getUser();
>>
>> class class_general
>> {
>>      function method_loadUser($params, $error)
>>      {
>>        $json=new JSON();
>>        return $json->encode($juser );
>>      }
>> }
>> -------------------
>> If I add the line that says "FAILS", nothing works, but I don't get an
>> error message in the log files (as with all errors in my class methods).
>> without this line of course the rest of the file will fail.
>> the strange thing is if I make a php file with these lines without the
>> class and methods (but just the includes and joomla stuff) it works
>> properly:
>> <?php
>> define( '_JEXEC', 1 );
>> define('JPATH_BASE', '/var/www/vhosts/noobizz.com/httpdocs/joomla' );
>> 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();
>>
>> $mainframe->route();
>> $user =& JFactory::getUser();
>>
>> print_r($user);
>>
>> echo "dit was het dan";
>> ?>
>>
>>
>> my questions:
>> -why are the errors not written to the error log files?
>> -why does it work in the last example but not in the qooxdoo php backend?
>> -Any people out there that have a way to use the php backend and get
>> proper error messaging?
>> -How do you guys/girls debug your php backend?
>> -Did anybody use qooxdoo php backend with the Joomla framework?
>>
>> thanks in advance.
>>
>> Farid

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: debugging php json backend

Farid Elyahyaoui-2
thanks for the suggestion. I thought of this too and did a 'grep' on this variable name.
nothing!
I nailed it down to one line (368) after which all variables defined before this line are not known
anymore in the index.php file:

if ((@include servicePathPrefix . $servicePath . ".php") === false)

after this line all variables defined before this line are not known anymore. Even fake variables
with long unique names.
Does this sound familiar to anyone?
it probably has to do with the variable scope in combination with the 'include' statement.
Please help.

Farid



Alexander Back schreef:

> Hi Farid,
>
> I'm no PHP expert, but do you have already searched for this variable
> name in the framework.php file? Maybe this file also uses this variable
> name and things get mixed up.
>
> Just a guess ...
>
> cheers,
>    Alex
>
> farid wrote:
>> I know a bit more now.
>> I stripped the php file to the bare minimum and in the error log I now
>> see the line:
>> ------------
>> [client 86.86.79.205] PHP Notice:  Undefined variable:
>> serviceComponents in
>> /var/www/vhosts/noobizz.com/httpdocs/services/index.php on line 378,
>> referer:
>> http://noobizz.com/qooxdoo/0.7.2/qooxdoo-0.7.2-skeleton/helloworld/source/view.php
>> ---------------
>>
>> line 378 in index.php from the standard php backend says:
>>
>> $className = "class_" . $serviceComponents[count($serviceComponents) -1];
>>
>> but on line 346 the variable $serviceComponents is already defined:
>>
>> $serviceComponents = explode(".", $jsonInput->service);
>>
>> what could be the cause that on line 378 $serviceComponents is not known?
>> as said this only happens if I include the framework.php file.
>>
>> Farid
>>
>>
>>
>> farid schreef:
>>> Hi y'all,
>>>
>>> I'm steadily forwarding with my project that uses qooxdoo and the php
>>> backend. And I must say that qooxdoo rocks!
>>> It already contains a few thousand lines of source code, of which many
>>> in the backend.
>>> It uses classes as in the demo backend from the qooxdoo project.
>>> Debugging has been cumbersome using print statements in the php file and
>>> looking in the apache/php error files of my webserver to see what
>>> happened. For some reason the errors in the methods of the classes don't
>>> generate errors in the error-log files so I always used print statements.
>>> Now I have a problem which I can't solve this way.
>>>
>>> I'm trying to integrate the new joomla 1.5 framework (see
>>> http://forum.joomla.org/viewtopic.php?f=304&p=1332208) but there is an
>>> error when I include the joomla framework file:
>>> --------------------------------
>>> ....
>>> //joomla stuff
>>> define( '_JEXEC', 1 );
>>> define('JPATH_BASE', '/var/www/vhosts/noobizz.com/httpdocs/joomla' );
>>> define( 'DS', DIRECTORY_SEPARATOR );
>>> require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
>>> require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );<---FAILS!
>>>
>>> $mainframe =& JFactory::getApplication('site');
>>> $mainframe->initialise();
>>> $mainframe->route();
>>> $juser =& JFactory::getUser();
>>>
>>> class class_general
>>> {
>>>      function method_loadUser($params, $error)
>>>      {
>>>        $json=new JSON();
>>>        return $json->encode($juser );
>>>      }
>>> }
>>> -------------------
>>> If I add the line that says "FAILS", nothing works, but I don't get an
>>> error message in the log files (as with all errors in my class methods).
>>> without this line of course the rest of the file will fail.
>>> the strange thing is if I make a php file with these lines without the
>>> class and methods (but just the includes and joomla stuff) it works
>>> properly:
>>> <?php
>>> define( '_JEXEC', 1 );
>>> define('JPATH_BASE', '/var/www/vhosts/noobizz.com/httpdocs/joomla' );
>>> 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();
>>>
>>> $mainframe->route();
>>> $user =& JFactory::getUser();
>>>
>>> print_r($user);
>>>
>>> echo "dit was het dan";
>>> ?>
>>>
>>>
>>> my questions:
>>> -why are the errors not written to the error log files?
>>> -why does it work in the last example but not in the qooxdoo php backend?
>>> -Any people out there that have a way to use the php backend and get
>>> proper error messaging?
>>> -How do you guys/girls debug your php backend?
>>> -Did anybody use qooxdoo php backend with the Joomla framework?
>>>
>>> thanks in advance.
>>>
>>> Farid
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: debugging php json backend

Derrell Lipman

On Mon, Jul 7, 2008 at 7:50 AM, farid <[hidden email]> wrote:
thanks for the suggestion. I thought of this too and did a 'grep' on this variable name.
nothing!
I nailed it down to one line (368) after which all variables defined before this line are not known
anymore in the index.php file:

if ((@include servicePathPrefix . $servicePath . ".php") === false)

after this line all variables defined before this line are not known anymore. Even fake variables
with long unique names.

This is very strange.  What file is being included?  i.e. what does

  servicePathPrefix . $servicePath . ".php"

expand to, and what is in that file?  Is that file manipulating any of the superglobal arrays, particularly $GLOBALS ?  Although I've never tried it, I suspect if you were to do unset($GLOBALS) or some such nastiness, you'd succeed in undefining all global variables.

Derrell


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: debugging php json backend

Farid Elyahyaoui-2
Hi Derrell,

it inded is strange so I kept searching.
I could trace it back to one line in the Joomla supplied framework.php file which causes the
variables to be unset:

JRequest::clean();

This has nothing to do obviously with the php backend of qooxdoo.
If I omit the line, the request is handled correctly and all the variables (like $serviceComponents)
contain valid values.
It still doesn't set the juser correctly but I have to find that out with the help of the Joomla
community.
One question though still stands:
what do you guys (no girls?;-) use to debug the php backend?

Farid

Derrell Lipman wrote:

>
> This is very strange.  What file is being included?  i.e. what does
>
>   servicePathPrefix . $servicePath . ".php"
>
> expand to, and what is in that file?  Is that file manipulating any of
> the superglobal arrays, particularly $GLOBALS ?  Although I've never
> tried it, I suspect if you were to do unset($GLOBALS) or some such
> nastiness, you'd succeed in undefining all global variables.
>
> Derrell
>
>



-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: debugging php json backend

Derrell Lipman
On Tue, Jul 8, 2008 at 7:30 AM, farid <[hidden email]> wrote:
One question though still stands:
what do you guys (no girls?;-) use to debug the php backend?

In most cases, we now have errors returned to the application and they can be displayed there.  You can also use the debug() function in index.php which appends its argument string to the file /tmp/phpinfo.  If you're tracking down a syntax error, you can often get good results by running index.php via the command-line interpretor, e.g. php5 -f index.php.  Writing a small script that sets $_SERVER["REQUEST_METHOD"] and $_GET["_ScriptTransport_id"] etc., should let you simulate an actual request, but I don't think I've ever actually needed to do this nor tried it.

Cheers,

Derrell


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel