You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Ted Yu <te...@yahoo.com> on 2009/10/28 18:17:18 UTC

include paths for PhpClient

I feel strange that I needed to patch include paths in PhpClient.php:

$GEN_DIR = '../gen-php';
require_once $GEN_DIR.'/shared/SharedService.php';
require_once $GEN_DIR.'/shared/shared_types.php';
require_once $GEN_DIR.'/tutorial/Calculator.php';
require_once $GEN_DIR.'/tutorial/tutorial_types.php';

Originally $GEN_DIR was used without shared and tutorial directories.

--- On Tue, 10/27/09, Anner van Hardenbroek <dw...@users.sourceforge.net> wrote:

> From: Anner van Hardenbroek <dw...@users.sourceforge.net>
> Subject: Re: undefined constant E_NONE
> To: thrift-user@incubator.apache.org
> Date: Tuesday, October 27, 2009, 5:16 PM
> Hi,
> 
> Just replace E_NONE with 0 (int), that will fix it.
> 
> Kind regards,
> -Anner.
> 
> --
> Anner van Hardenbroek
> dwlnetnl@users.sourceforge.net
> 
> On 28 okt 2009, at 00:30, Ted Yu wrote:
> 
> > Hi,
> > When running php client, I got:
> > PHP Notice:  Use of undefined constant E_NONE -
> assumed 'E_NONE' in / 
> > home/wr_webroot/thrift/tutorial/php/PhpClient.php on
> line 38
> > PHP Stack trace:
> > PHP   1. {main}()
> /home/thrift/tutorial/php/PhpClient.php:0
> >
> > I am using php 5.2.9
> >
> > Has anyone seen this ?
> >
> >
> >
> >
> >
> 
> 


      

RE: include paths for PhpClient

Posted by Mark Slee <ms...@facebook.com>.
The PHP generation assumes that after the build step you will move your code after generation into your own PHP source tree, where you define $GLOBALS['THRIFT_ROOT'], and your packages go in $GLOBALS['THRIFT_ROOT'].'/packages/'

The issue is that PHP includes are a bit of a nightmare to deal with, as the paths are always relative to the directory that the PHP interpreter is invoked from, not the directory that the file with the include statement resides in.

Thus, it is always best to use absolute paths in PHP include/require statements, and we use $GLOBALS['THRIFT_ROOT'] for this.

A bit clunky and adds one manual step to the process, but keeps the paths sane.

-----Original Message-----
From: Ted Yu [mailto:ted_yu@yahoo.com] 
Sent: Wednesday, October 28, 2009 10:17 AM
To: thrift-user@incubator.apache.org
Subject: include paths for PhpClient

I feel strange that I needed to patch include paths in PhpClient.php:

$GEN_DIR = '../gen-php';
require_once $GEN_DIR.'/shared/SharedService.php';
require_once $GEN_DIR.'/shared/shared_types.php';
require_once $GEN_DIR.'/tutorial/Calculator.php';
require_once $GEN_DIR.'/tutorial/tutorial_types.php';

Originally $GEN_DIR was used without shared and tutorial directories.

--- On Tue, 10/27/09, Anner van Hardenbroek <dw...@users.sourceforge.net> wrote:

> From: Anner van Hardenbroek <dw...@users.sourceforge.net>
> Subject: Re: undefined constant E_NONE
> To: thrift-user@incubator.apache.org
> Date: Tuesday, October 27, 2009, 5:16 PM
> Hi,
> 
> Just replace E_NONE with 0 (int), that will fix it.
> 
> Kind regards,
> -Anner.
> 
> --
> Anner van Hardenbroek
> dwlnetnl@users.sourceforge.net
> 
> On 28 okt 2009, at 00:30, Ted Yu wrote:
> 
> > Hi,
> > When running php client, I got:
> > PHP Notice:  Use of undefined constant E_NONE -
> assumed 'E_NONE' in / 
> > home/wr_webroot/thrift/tutorial/php/PhpClient.php on
> line 38
> > PHP Stack trace:
> > PHP   1. {main}()
> /home/thrift/tutorial/php/PhpClient.php:0
> >
> > I am using php 5.2.9
> >
> > Has anyone seen this ?
> >
> >
> >
> >
> >
> 
> 


      

RE: datetime type in thrift

Posted by Mark Slee <ms...@facebook.com>.
Just to quickly chime in, I basically agree with what's already been said here. Philosophically, we wanted to constrain the set of built-in Thrift types to only those that are very common across all programming languages. This, for instance, is why we even decided against supporting unsigned integers.

Though similar datetime implementations do exist in many languages, there is no real standard for how to represent a datetime in all programming languages, or over the network. Thrift would be sort of inventing a type here. Most languages that do support a datetime type of some sort offer very simple APIs to construct datetime objects from milli/micro-second counters.

In my opinion, if you're not bundling timezone info in them, datetime objects offer little benefit over using milli/micro-seconds since the epoch. And supporting timezones in any form is something I'd definitely rather not ever see pushed down into the Thrift layer.

Cheers,
Mark

-----Original Message-----
From: Matthieu Imbert [mailto:matthieu.imbert@ens-lyon.fr] 
Sent: Wednesday, October 28, 2009 12:49 PM
To: thrift-user@incubator.apache.org
Subject: Re: datetime type in thrift

Ted Yu wrote:
>>>From my experience working with web services using SOAP in PHP and Java, datetime handling is a source of big headache.
> 
> Is there plan for thrift to add datetime type support ?
> 
> I see alternative such as:
> http://www.evernote.com/about/developer/api/ref/Types.html#Typedef_Timestamp
> 
> Regards

i use this:

struct Timestamp {
  1: i32 s = -2147483648,
  2: i32 micro_s = 0,
}

-- 
Matthieu

Re: datetime type in thrift

Posted by Matthieu Imbert <ma...@ens-lyon.fr>.
Ted Yu wrote:
>>>From my experience working with web services using SOAP in PHP and Java, datetime handling is a source of big headache.
> 
> Is there plan for thrift to add datetime type support ?
> 
> I see alternative such as:
> http://www.evernote.com/about/developer/api/ref/Types.html#Typedef_Timestamp
> 
> Regards

i use this:

struct Timestamp {
  1: i32 s = -2147483648,
  2: i32 micro_s = 0,
}

-- 
Matthieu

Re: datetime type in thrift

Posted by Bryan Duxbury <br...@rapleaf.com>.
Here, we use either milliseconds since epoch or seconds since epoch,  
depending on what amount of granularity we need.

-Bryan

On Oct 28, 2009, at 11:25 AM, Ted Yu wrote:

> From my experience working with web services using SOAP in PHP and  
> Java, datetime handling is a source of big headache.
>
> Is there plan for thrift to add datetime type support ?
>
> I see alternative such as:
> http://www.evernote.com/about/developer/api/ref/ 
> Types.html#Typedef_Timestamp
>
> Regards
>
>
>


Re: datetime type in thrift

Posted by Dave Engberg <de...@evernote.com>.
Our definition of 'timestamp' is a bit clunky, yes.  We're using 
millisecond resolution because this happened to map well into our 
service implementation (in Java).
Ignoring the milliseconds is even more embarrassing -- we're storing the 
times in MySQL, which can't handle sub-millisecond resolution in its 
date/time fields.  (We found this out too late to resolve easily, etc.)


Michael Greene wrote:
> We are using microseconds-since-epoch here.  One downside to this
> approach from an interop perspective is the ease at which Java,
> Javascript, and UNIX in general deal with milliseconds-since-epoch vs.
> microseconds.  If I didn't need microseconds for business reasons, I
> would use milliseconds.  When I asked around on #thrift awhile back,
> that was the most common approach.
>
> Michael
>
> On Wed, Oct 28, 2009 at 1:29 PM, David Reiss <dr...@facebook.com> wrote:
>   
>> I would suggest doing something similar to what Evernote is doing.
>> (Though if you're using an i64, you might as well use microseconds.)
>>
>> --David
>>
>> Ted Yu wrote:
>>     
>>> From my experience working with web services using SOAP in PHP and Java, datetime handling is a source of big headache.
>>>
>>> Is there plan for thrift to add datetime type support ?
>>>
>>> I see alternative such as:
>>> http://www.evernote.com/about/developer/api/ref/Types.html#Typedef_Timestamp
>>>
>>> Regards
>>>
>>>
>>>
>>>       

Re: datetime type in thrift

Posted by Michael Greene <mi...@gmail.com>.
We are using microseconds-since-epoch here.  One downside to this
approach from an interop perspective is the ease at which Java,
Javascript, and UNIX in general deal with milliseconds-since-epoch vs.
microseconds.  If I didn't need microseconds for business reasons, I
would use milliseconds.  When I asked around on #thrift awhile back,
that was the most common approach.

Michael

On Wed, Oct 28, 2009 at 1:29 PM, David Reiss <dr...@facebook.com> wrote:
> I would suggest doing something similar to what Evernote is doing.
> (Though if you're using an i64, you might as well use microseconds.)
>
> --David
>
> Ted Yu wrote:
>> From my experience working with web services using SOAP in PHP and Java, datetime handling is a source of big headache.
>>
>> Is there plan for thrift to add datetime type support ?
>>
>> I see alternative such as:
>> http://www.evernote.com/about/developer/api/ref/Types.html#Typedef_Timestamp
>>
>> Regards
>>
>>
>>
>

Re: datetime type in thrift

Posted by Ted Yu <te...@yahoo.com>.
I noticed there isn't type called object in thrift.

thrift can actually pass i64 as timestamp across the wire and define methods that convert i64 to native datetime type in each language.

Meaning thrift can handle serialization/deserialization of timestamp type transparently.

--- On Wed, 10/28/09, David Reiss <dr...@facebook.com> wrote:

> From: David Reiss <dr...@facebook.com>
> Subject: Re: datetime type in thrift
> To: "thrift-user@incubator.apache.org" <th...@incubator.apache.org>
> Date: Wednesday, October 28, 2009, 11:29 AM
> I would suggest doing something
> similar to what Evernote is doing.
> (Though if you're using an i64, you might as well use
> microseconds.)
> 
> --David
> 
> Ted Yu wrote:
> > From my experience working with web services using
> SOAP in PHP and Java, datetime handling is a source of big
> headache.
> > 
> > Is there plan for thrift to add datetime type support
> ?
> > 
> > I see alternative such as:
> > http://www.evernote.com/about/developer/api/ref/Types.html#Typedef_Timestamp
> > 
> > Regards
> > 
> > 
> >       
> 


      

Re: datetime type in thrift

Posted by David Reiss <dr...@facebook.com>.
I would suggest doing something similar to what Evernote is doing.
(Though if you're using an i64, you might as well use microseconds.)

--David

Ted Yu wrote:
> From my experience working with web services using SOAP in PHP and Java, datetime handling is a source of big headache.
> 
> Is there plan for thrift to add datetime type support ?
> 
> I see alternative such as:
> http://www.evernote.com/about/developer/api/ref/Types.html#Typedef_Timestamp
> 
> Regards
> 
> 
>       

datetime type in thrift

Posted by Ted Yu <te...@yahoo.com>.
>From my experience working with web services using SOAP in PHP and Java, datetime handling is a source of big headache.

Is there plan for thrift to add datetime type support ?

I see alternative such as:
http://www.evernote.com/about/developer/api/ref/Types.html#Typedef_Timestamp

Regards


      

Re: include paths for PhpClient

Posted by James Clarke <cl...@gmail.com>.
This is filed and patched as THRIFT-592 <
https://issues.apache.org/jira/browse/THRIFT-592> but not committed.

This is a quirk of how the tutorial is written.  In application code you
could only need one include (if you follow the guidelines in
/thrift/lib/php/README):

require_once $GLOBALS['THRIFT_ROOT'].'/packages/tutorial/Calculator.php';


On Wed, Oct 28, 2009 at 12:17, Ted Yu <te...@yahoo.com> wrote:

> I feel strange that I needed to patch include paths in PhpClient.php:
>
> $GEN_DIR = '../gen-php';
> require_once $GEN_DIR.'/shared/SharedService.php';
> require_once $GEN_DIR.'/shared/shared_types.php';
> require_once $GEN_DIR.'/tutorial/Calculator.php';
> require_once $GEN_DIR.'/tutorial/tutorial_types.php';
>
> Originally $GEN_DIR was used without shared and tutorial directories.
>
> --- On Tue, 10/27/09, Anner van Hardenbroek <
> dwlnetnl@users.sourceforge.net> wrote:
>
> > From: Anner van Hardenbroek <dw...@users.sourceforge.net>
> > Subject: Re: undefined constant E_NONE
> > To: thrift-user@incubator.apache.org
> > Date: Tuesday, October 27, 2009, 5:16 PM
> > Hi,
> >
> > Just replace E_NONE with 0 (int), that will fix it.
> >
> > Kind regards,
> > -Anner.
> >
> > --
> > Anner van Hardenbroek
> > dwlnetnl@users.sourceforge.net
> >
> > On 28 okt 2009, at 00:30, Ted Yu wrote:
> >
> > > Hi,
> > > When running php client, I got:
> > > PHP Notice:  Use of undefined constant E_NONE -
> > assumed 'E_NONE' in /
> > > home/wr_webroot/thrift/tutorial/php/PhpClient.php on
> > line 38
> > > PHP Stack trace:
> > > PHP   1. {main}()
> > /home/thrift/tutorial/php/PhpClient.php:0
> > >
> > > I am using php 5.2.9
> > >
> > > Has anyone seen this ?
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>
>
>