[ 
https://issues.apache.org/jira/browse/THRIFT-1330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13157564#comment-13157564
 ] 

Mike Riley commented on THRIFT-1330:
------------------------------------

Jake:

I'm a little confused at this point because I just looked back over the 
revision history for the autoloader and it doesn't seem to have ever changed.  
The autoloader works by reading out of the $GLOBALS array to find the path to 
the specified resource. It should function correctly irrespective of any 
directory structure assuming you're writing out paths correctly into $GLOBALS.  
What does worry me is that there seems to be a php.path namespace declarator, 
undocumented, which you can set in your thrift file.  I haven't explored what 
this does but I'm betting it will function similar to what you are expecting, 
which I assume is Zend style autoloading based on folder hierarchies matching 
class prefixes. I'm betting we have some kind of disconnect here on a basic 
level as far as how autoloading is supposed to work, which admittedly is 
probably my fault because I'm very new to thrift.

The specific example you emailed me, Thrift_Test_VersioningTestV1, to the best 
of my understanding, functions as expected.  I changed my namespace to 
Thrift.Test, which was properly prefixed to the class name in the declaration, 
usage would be as follows:

1. Included autoload.php in your script. 
2. Include the ThriftTest_types.php file to load the autoload paths.
3. Invoke 'new Thrift_Test_VersioningTestV1()'

This will cause the autoloader to find the following entry:

$GLOBALS['THRIFT_AUTOLOAD']['thrift_test_versioningtestv1'] = 
'ThriftTest/ThriftTest.VersioningTestV1.php';

And correctly determine the path to the requested class allowing you to load it.

Could you try and clarify what the issue is here?
                
> PHP Namespaces no longer generated
> ----------------------------------
>
>                 Key: THRIFT-1330
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1330
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler
>    Affects Versions: 0.7, 0.8
>         Environment: Mac OS X 10.6.8, CentOS 5.6, Ubuntu 11.04
>            Reporter: B Armstrong
>            Assignee: Jake Farrell
>            Priority: Critical
>             Fix For: 0.8
>
>         Attachments: thrift-1392-1330.patch, thrift-1392-1330r1.patch
>
>
> PHP namespaces are not being generated, ever. PHP 5.3 namespace aren't 
> generated either.
> The following will illustrate the bug. This works in Thrift 0.6.*
> $ thrift -version
> Thrift version 0.7.0
> $ cat > test.thrift
> namespace php TestNamespace
> struct ItemX {}
> $ thrift --gen php test.thrift
> $ grep "TestNamespace" gen-php/test/test_types.php && echo "Has namespace" || 
> echo "NO NAMESPACE FOUND"
> NO NAMESPACE FOUND
> $ thrift -version
> Thrift version 0.8.0-dev
> $ thrift -gen php test.thrift 
> $ grep "TestNamespace" gen-php/test/test_types.php && echo "Has namespace" || 
> echo "NO NAMESPACE FOUND"
> NO NAMESPACE FOUND

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to