|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
I'm trying to use a (remote) COM object from a PHP script (4.4, server has apache2 win32). The basics seem to work : I instantiate the COM object ($o = new COM"..."), then I use two of the objects methods to authenticate. In the meantime a property called "ProjectConnected", passes from 0 to 1. So I think the object is correctly instanciated and the connection works. But now, I'm doing a var_dump on my object and I get this : object(COM)(1) { [0]=> resource(127) of type (COM) } Arg. I don't understand this and the PHP manual doesnt either. I would have expected to get a list of methods/properties. At least the two I use to authenticate. var_dump ($obj[0]) returns null. Could someone explain me more about this ? Thanks, -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Alex wrote:
> Hello, > > I'm trying to use a (remote) COM object from a PHP script (4.4, server has > apache2 win32). > > The basics seem to work : I instantiate the COM object ($o = new COM"..."), > then I use two of the objects methods to authenticate. In the meantime a > property called "ProjectConnected", passes from 0 to 1. So I think the > object is correctly instanciated and the connection works. > > But now, I'm doing a var_dump on my object and I get this : > object(COM)(1) { > [0]=> resource(127) of type (COM) > } > > Arg. I don't understand this and the PHP manual doesnt either. I would > have expected to get a list of methods/properties. At least the two I use to > authenticate. > > var_dump ($obj[0]) returns null. > > > Could someone explain me more about this ? > > Thanks, This is correct; this is an external resource in PHP. AFAIK, the only way you can get a list of properties and methods of a COM object is if the COM object itself supports such a request. And the resource object in PHP isn't an array, which is why you get null when you try to dump $obj[0]. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:a9qdnbh_IexubqfanZ2dnUVZ_gidnZ2d@comcast.com. .. > This is correct; this is an external resource in PHP. > > AFAIK, the only way you can get a list of properties and methods of a COM > object is if the COM object itself supports such a request. OK, I get it ! Is there a standard/usual way to get the list of methods/properties that are published ? I don't have much documentation about the object I want to target (and examples are in VB - not very useful to me as a beginner). > And the resource object in PHP isn't an array, which is why you get null > when you try to dump $obj[0]. Then, what's the meaning of this [0] for resources ? In the meantime I'm looking up the PHP doc for this resource type. I didn't know it. Thanks for your answer, it's very useful. -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Nov 14, 10:56 am, "Alex" <d_key...@hotmail.com> wrote:
.... > I'm trying to use a (remote) COM object from a PHP script (4.4, server has > apache2 win32). > > The basics seem to work : I instantiate the COM object ($o = new COM"..."), .... > But now, I'm doing a var_dump on my object and I get this : > object(COM)(1) { > [0]=> resource(127) of type (COM) > } > > Arg. I don't understand this and the PHP manual doesnt either. I would > have expected to get a list of methods/properties. At least the two I use to > authenticate. Check out: http://php.net/com_print_typeinfo Csaba Gabor from Vienna |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
....
subsequent question : gettype returns "object". Shouldnt it return "resource" ? As a matter of fact get_resource_type returns nothing at all, nor does com_print_typeinfo . What can I deduct ? simply that the object just doesnt support some requests allowing to have this kind of info ? -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
"Alex" <d_keyoke@hotmail.com> wrote in message news:473afd55$0$6169$426a74cc@news.free.fr... > "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message > news:a9qdnbh_IexubqfanZ2dnUVZ_gidnZ2d@comcast.com. .. > >> This is correct; this is an external resource in PHP. >> >> AFAIK, the only way you can get a list of properties and methods of a COM >> object is if the COM object itself supports such a request. > > OK, I get it ! Is there a standard/usual way to get the list of > methods/properties that are published ? I don't have much documentation > about the object I want to target (and examples are in VB - not very > useful to me as a beginner). as in, you're a beginner to VB or, a beginner to php? i'd create a component if you need to break this and other com objects apart like this. if you're using vb classic (the crusty old version), there are several free and well written libraries that can expose any com object's interfaces...including types, params, etc. if you're using vb.net, use it's reflection capabilities to do the same. give your vb app the path to the dll, let it create it, and then go about discovering its make-up. either way, compile it to a com object to make it accessible to php. btw, if using vb.net, you don't have to create in php the object being exposed. your reflection-enabled com object can not only break-down the interfaces for you, but you can also put 'invoke' methods on your object which defers to the interface of the child object being exposed to php. make sense? |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
"Steve" <no.one@example.com> wrote in message
news:LsE_i.19$wL7.17@newsfe07.lga... > as in, you're a beginner to VB or, a beginner to php? to COM and I havent touched VB since..... Win 3.11. I've been codingin PHP for almost 10 years, but never had to use COM. > i'd create a component if you need to break this and other com objects > apart like this. > > if you're using vb classic (the crusty old version), there are several > free and well written libraries that can expose any com object's > interfaces...including types, params, etc. > > if you're using vb.net, use it's reflection capabilities to do the same. > give your vb app the path to the dll, let it create it, and then go about > discovering its make-up. > > either way, compile it to a com object to make it accessible to php. btw, > if using vb.net, you don't have to create in php the object being exposed. > your reflection-enabled com object can not only break-down the interfaces > for you, but you can also put 'invoke' methods on your object which defers > to the interface of the child object being exposed to php. make sense? The object is already compiled. It's from a software vendor. I meant to say that I have doc with the object, but all the examples of object usage are in VB, which I have long forgotten. They use lists, for example all around the place, and I don't remember how to translate this to PHP ![]() -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
"Csaba Gabor" <danswer@gmail.com> wrote in message news:1195050450.117726.188090@57g2000hsv.googlegro ups.com... > Check out: > http://php.net/com_print_typeinfo I know how to RTFM ![]() Things are getting a bit "better" now : I replaced new COM() by com_load() and voila, I have com_print_typeinfo working. Now I have to understand how to access those lists they speak about in the doc. That got rid of the errors "is not a COM object handler" I had in the PHP log which I just had enabled. -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
"Alex" <d_keyoke@hotmail.com> wrote in message news:473b2213$0$20126$426a74cc@news.free.fr... > "Steve" <no.one@example.com> wrote in message > news:LsE_i.19$wL7.17@newsfe07.lga... >> as in, you're a beginner to VB or, a beginner to php? > > to COM and I havent touched VB since..... Win 3.11. I've been coding> in PHP for almost 10 years, but never had to use COM. > >> i'd create a component if you need to break this and other com objects >> apart like this. >> >> if you're using vb classic (the crusty old version), there are several >> free and well written libraries that can expose any com object's >> interfaces...including types, params, etc. >> >> if you're using vb.net, use it's reflection capabilities to do the same. >> give your vb app the path to the dll, let it create it, and then go about >> discovering its make-up. >> >> either way, compile it to a com object to make it accessible to php. btw, >> if using vb.net, you don't have to create in php the object being >> exposed. your reflection-enabled com object can not only break-down the >> interfaces for you, but you can also put 'invoke' methods on your object >> which defers to the interface of the child object being exposed to php. >> make sense? > > The object is already compiled. that wasn't the point i was making above...at all. however, no need to get into that since that suggestion isn't your intended purpose. > It's from a software vendor. I meant to say that I have doc with the > object, but all the examples of object usage are in VB, which I have long > forgotten. They use lists, for example all around the place, and I don't > remember how to translate this to PHP ![]() so, you know the object's interfaces...just not how to code it in php? same way as any other object... $o->interface; $o->interface(param); etc. am i missing something? |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
"Steve" <no.one@example.com> wrote in message
news dG_i.89$qJ1.84@newsfe06.lga...>> It's from a software vendor. I meant to say that I have doc with the >> object, but all the examples of object usage are in VB, which I have long >> forgotten. They use lists, for example all around the place, and I don't >> remember how to translate this to PHP ![]() > > so, you know the object's interfaces...just not how to code it in php? > same way as any other object... > > $o->interface; > $o->interface(param); > etc. > > am i missing something? I'm pretty sure you're missing a lot less than I do ![]() But it's getting better. I replaced "new COM()" by com_load() and now I can use com_print_typeinfo which returns all the innards of the object. I don't really know why com_load works better, but it is the case. I also got to access one of the lists in the object. $....->item($i) . I'm not sure whether it's a special syntax instead of item[$i] or those item()s are really functions. So things are getting better ![]() However, my next blocking point is something called a factory. It is a property of my COM object that is itself an ever-existing instance of a class containing other objects. I think it is instanciated automatically by the COM server when I create the object. Everytime I put its name in my code ( $a =$obj->Factory; nothing more ), Apache bombs with no explanation. I have put the memory limit for PHP to 128M just to see but it doesnt change anything. -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
"Alex" <d_keyoke@hotmail.com> wrote in message news:473b3bee$0$30024$426a74cc@news.free.fr... > "Steve" <no.one@example.com> wrote in message > news dG_i.89$qJ1.84@newsfe06.lga...>>> It's from a software vendor. I meant to say that I have doc with the >>> object, but all the examples of object usage are in VB, which I have >>> long forgotten. They use lists, for example all around the place, and I >>> don't remember how to translate this to PHP ![]() >> >> so, you know the object's interfaces...just not how to code it in php? >> same way as any other object... >> >> $o->interface; >> $o->interface(param); > >> etc. >> >> am i missing something? > > I'm pretty sure you're missing a lot less than I do ![]() > > But it's getting better. I replaced "new COM()" by com_load() and now I > can use com_print_typeinfo which returns all the innards of the object. I > don't really know why com_load works better, but it is the case. > > I also got to access one of the lists in the object. $....->item($i) . I'm > not sure whether it's a special syntax instead of item[$i] or those > item()s are really functions. > > So things are getting better ![]() > > > However, my next blocking point is something called a factory. It is a > property of my COM object that is itself an ever-existing instance of a > class containing other objects. I think it is instanciated automatically > by the COM server when I create the object. > > Everytime I put its name in my code ( $a =$obj->Factory; nothing more ), try: $a = $obj->Factory(); |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
"Alex" <d_keyoke@hotmail.com> wrote in message news:473b3bee$0$30024$426a74cc@news.free.fr... > "Steve" <no.one@example.com> wrote in message > news dG_i.89$qJ1.84@newsfe06.lga...>>> It's from a software vendor. I meant to say that I have doc with the >>> object, but all the examples of object usage are in VB, which I have >>> long forgotten. They use lists, for example all around the place, and I >>> don't remember how to translate this to PHP ![]() >> >> so, you know the object's interfaces...just not how to code it in php? >> same way as any other object... >> >> $o->interface; >> $o->interface(param); > >> etc. >> >> am i missing something? > > I'm pretty sure you're missing a lot less than I do ![]() > > But it's getting better. I replaced "new COM()" by com_load() and now I > can use com_print_typeinfo which returns all the innards of the object. I > don't really know why com_load works better, but it is the case. > > I also got to access one of the lists in the object. $....->item($i) . I'm > not sure whether it's a special syntax instead of item[$i] or those > item()s are really functions. > > So things are getting better ![]() > > > However, my next blocking point is something called a factory. It is a > property of my COM object that is itself an ever-existing instance of a > class containing other objects. I think it is instanciated automatically > by the COM server when I create the object. > > Everytime I put its name in my code ( $a =$obj->Factory; nothing more ), > Apache bombs with no explanation. > > I have put the memory limit for PHP to 128M just to see but it doesnt > change anything. Oh there's something I just realized. This "factory" object is an instance of a class called Factory. But the doc also makes mention of something called an interface (IFactory) who has the same methods/Properties of the class. When I do a com_print_typeinfo on the Factory, I get almost nothing : class Factory { /* GUID={F4E856D4-FCD7-11D4-9D8A-0001029DEAF5} */ }When I do it on the interface, I get all my object's properties. There HAS to be a difference ![]() -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#13 |
|
Messages: n/a
Hébergeur: |
"Steve" <no.one@example.com> wrote in message
news:86H_i.35$wL7.20@newsfe07.lga... > try: > > $a = $obj->Factory(); Just did it.... Apache inflates to 51M of RAM usage and bombs. grmf ![]() -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#14 |
|
Messages: n/a
Hébergeur: |
"Alex" <d_keyoke@hotmail.com> wrote in message news:473b3ff8$0$20124$426a74cc@news.free.fr... > "Steve" <no.one@example.com> wrote in message > news:86H_i.35$wL7.20@newsfe07.lga... > >> try: >> >> $a = $obj->Factory(); > > Just did it.... Apache inflates to 51M of RAM usage and bombs. grmf ![]() did you say you set your memory limit to -1 (unlimited) in php? does Factory take a param to just return a single item? the good new is that it seem to be just a memory issue at this point. |
|
|
|
#15 |
|
Messages: n/a
Hébergeur: |
"Alex" <d_keyoke@hotmail.com> wrote in message news:473b3f32$0$29354$426a74cc@news.free.fr... > > "Alex" <d_keyoke@hotmail.com> wrote in message > news:473b3bee$0$30024$426a74cc@news.free.fr... >> "Steve" <no.one@example.com> wrote in message >> news dG_i.89$qJ1.84@newsfe06.lga...>>>> It's from a software vendor. I meant to say that I have doc with the >>>> object, but all the examples of object usage are in VB, which I have >>>> long forgotten. They use lists, for example all around the place, and I >>>> don't remember how to translate this to PHP ![]() >>> >>> so, you know the object's interfaces...just not how to code it in php? >>> same way as any other object... >>> >>> $o->interface; >>> $o->interface(param); >> >>> etc. >>> >>> am i missing something? >> >> I'm pretty sure you're missing a lot less than I do ![]() >> >> But it's getting better. I replaced "new COM()" by com_load() and now I >> can use com_print_typeinfo which returns all the innards of the object. I >> don't really know why com_load works better, but it is the case. >> >> I also got to access one of the lists in the object. $....->item($i) . >> I'm not sure whether it's a special syntax instead of item[$i] or those >> item()s are really functions. >> >> So things are getting better ![]() >> >> >> However, my next blocking point is something called a factory. It is a >> property of my COM object that is itself an ever-existing instance of a >> class containing other objects. I think it is instanciated automatically >> by the COM server when I create the object. >> >> Everytime I put its name in my code ( $a =$obj->Factory; nothing more ), >> Apache bombs with no explanation. >> >> I have put the memory limit for PHP to 128M just to see but it doesnt >> change anything. > > Oh there's something I just realized. > > This "factory" object is an instance of a class called Factory. But the > doc also makes mention of something called an interface (IFactory) who has > the same methods/Properties of the class. When I do a com_print_typeinfo > on the Factory, I get almost nothing : > class Factory { /* GUID={F4E856D4-FCD7-11D4-9D8A-0001029DEAF5} */ > }When I do it on the interface, I get all my object's properties. > > There HAS to be a difference ![]() a difference, yes. something that will make your code quit bombing and still get the Factory functionality...probably not. all an interface (IFactory in this case) is, is a contract...a definition of what *all usable* objects that *implement* that interface will provide a caller, i.e. your php code. make sense? IFactory will provide you no other functionality than that. here's an example in vb. public interface iFactory public property foo as integer end interface public class sawMill implements iFactory public property get foo() implements iFactory.foo get return 666 end get set (byval value as integer) # do nothing...however, set is *required* # because iFactory is read/write end property public function saw() debug.print "sawing..." end function end class public class brewery implements iFactory private myFoo as integer public property get foo() implements iFactory.foo get return myFoo end get set (byval value as integer) myFoo = value end property public function brew() debug.print "brewing " & myFoo end function end class in the above, both completely unrelated classes (sawMill and brewery) have iFactory.foo as part of their definition. how they implement them is different, but each must have a read and write foo. if i simply say: private myFactory as iFactory and then try: myFactory.foo() it will do nothing. myFactory is an interface that has no working parts. however, if i do: private myFactory as iFactory = new brewery myFactory.foo = 15 i'll get somewhere. notice that the above works whether or not i set myFactory to new brewery OR sawMill. both have a foo interface. however, if i continue the above code with: myFactory.saw() it'll blow up. both saw and brew are specific interfaces defined by each class respectively...not by iFactory. let's say that myFactory is set somewhere unbeknownst to me, how would i take specific action? public function factoryToString(byval factory as iFactory, byval fooValue as integer) factory.foo = fooValue if typeof factory is sawMill then factory.saw() end if if typeof factory is brewery then factory.brew() end if end function anyway...i think i got off track, but does that you know that you're going to have to get at an actual Factory object in the list...which doesn't solve your memory problem? |
|
|
|
#16 |
|
Messages: n/a
Hébergeur: |
"Steve" <no.one@example.com> wrote in message
news:IlH_i.41$wL7.37@newsfe07.lga... > did you say you set your memory limit to -1 (unlimited) in php? @#^#%&$^ :-) I didn't see this one come. I'm setting it to something else then. > > does Factory take a param to just return a single item? > > the good new is that it seem to be just a memory issue at this point. No parameter is mentionned in the documentation ![]() -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#17 |
|
Messages: n/a
Hébergeur: |
"Steve" <no.one@example.com> wrote in message
news:mKH_i.34$dm.33@newsfe02.lga... > a difference, yes. something that will make your code quit bombing and > still get the Factory functionality...probably not. all an interface > (IFactory in this case) is, is a contract...a definition of what *all > usable* objects that *implement* that interface will provide a caller, > i.e. your php code. make sense? IFactory will provide you no other > functionality than that. here's an example in vb. OK it's like a class from which another inherits, then ? (snip the example) > anyway...i think i got off track, but does that you know that you're > going to have to get at an actual Factory object in the list...which > doesn't solve your memory problem? Yes, that's very ful. But it raises a question in PHP. Can I assume that COM tells PHP what type the objects in a class (or Interface) are ? I don't have to explicitely instanciate or cast the objects that are childs of a COM object ? Now, I tried different values for memory_limit in php.ini and it doesnt change anything. I had a closer look at the memory usage, and Apache also takes almost 50M on a working page. So I'm not really sure it's a memory problem. Actually, the COM syntax is not really complicated. So I'm beginning to think of a bug (in the object or PHP). I'm considering trying a newer version of PHP. But I fear the impacts. Thank you very much again, things are getting clearer ![]() -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#18 |
|
Messages: n/a
Hébergeur: |
"Alex" <d_keyoke@hotmail.com> wrote in message news:473bf12b$0$25948$426a74cc@news.free.fr... > "Steve" <no.one@example.com> wrote in message > news:IlH_i.41$wL7.37@newsfe07.lga... >> did you say you set your memory limit to -1 (unlimited) in php? > > @#^#%&$^ :-) > > I didn't see this one come. I'm setting it to something else then. > >> >> does Factory take a param to just return a single item? >> >> the good new is that it seem to be just a memory issue at this point. > > No parameter is mentionned in the documentation ![]() Hi again. Chances are it is a bug in PHP 4.4. I upgraded to PHP 5.2.5, and everything works naturally as expected. I can use the COM object with the "->" operator and the "Factory" thing contains items I can manipulate. Now I can concentrate on the functionnality. Thanks again, Steve. Your posts have made lots of things clearer in my mind. -- Alex [JDR] Visitez Extremia, un monde gratuit et en francais pour D&D et autres jeux de role. www.extremia.org |
|
|
|
#19 |
|
Messages: n/a
Hébergeur: |
Steve, thanks for your awesome exposition on VB interfaces, replete
with example. This type of post is all too rare on the web. Csaba On Nov 14, 8:10 pm, "Steve" <no....@example.com> wrote: > "Alex" <d_key...@hotmail.com> wrote in message .... > a difference, yes. something that will make your code quit bombing and still > get the Factory functionality...probably not. all an interface (IFactory in > this case) is, is a contract...a definition of what *all usable* objects > that *implement* that interface will provide a caller, i.e. your php code. > make sense? IFactory will provide you no other functionality than that. > here's an example in vb. > > public interface iFactory > public property foo as integer > end interface > > public class sawMill > implements iFactory > public property get foo() implements iFactory.foo > get > return 666 > end get > set (byval value as integer) > # do nothing...however, set is *required* > # because iFactory is read/write > end property > public function saw() > debug.print "sawing..." > end function > end class > > public class brewery > implements iFactory > private myFoo as integer > public property get foo() implements iFactory.foo > get > return myFoo > end get > set (byval value as integer) > myFoo = value > end property > public function brew() > debug.print "brewing " & myFoo > end function > end class > > in the above, both completely unrelated classes (sawMill and brewery) have > iFactory.foo as part of their definition. how they implement them is > different, but each must have a read and write foo. > > if i simply say: > > private myFactory as iFactory > > and then try: > > myFactory.foo() > > it will do nothing. myFactory is an interface that has no working parts. > however, if i do: > > private myFactory as iFactory = new brewery > myFactory.foo = 15 > > i'll get somewhere. notice that the above works whether or not i set > myFactory to new brewery OR sawMill. both have a foo interface. however, if > i continue the above code with: > > myFactory.saw() > > it'll blow up. both saw and brew are specific interfaces defined by each > class respectively...not by iFactory. let's say that myFactory is set > somewhere unbeknownst to me, how would i take specific action? > > public function factoryToString(byval factory as iFactory, byval fooValue as > integer) > factory.foo = fooValue > if typeof factory is sawMill then > factory.saw() > end if > if typeof factory is brewery then > factory.brew() > end if > end function > > anyway...i think i got off track, but does that you know that you're > going to have to get at an actual Factory object in the list...which doesn't > solve your memory problem? |
|
|
|
#20 |
|
Messages: n/a
Hébergeur: |
"Alex" <d_keyoke@hotmail.com> wrote in message news:473c20ab$0$20122$426a74cc@news.free.fr... > > "Alex" <d_keyoke@hotmail.com> wrote in message > news:473bf12b$0$25948$426a74cc@news.free.fr... >> "Steve" <no.one@example.com> wrote in message >> news:IlH_i.41$wL7.37@newsfe07.lga... >>> did you say you set your memory limit to -1 (unlimited) in php? >> >> @#^#%&$^ :-) >> >> I didn't see this one come. I'm setting it to something else then. >> >>> >>> does Factory take a param to just return a single item? >>> >>> the good new is that it seem to be just a memory issue at this point. >> >> No parameter is mentionned in the documentation ![]() > > Hi again. > > Chances are it is a bug in PHP 4.4. > > I upgraded to PHP 5.2.5, and everything works naturally as expected. I can > use the COM object with the "->" operator and the "Factory" thing contains > items I can manipulate. > > Now I can concentrate on the functionnality. > > Thanks again, Steve. Your posts have made lots of things clearer in my > mind. no problem. i'm glad it works for you now. cheers. |
|
|
|
#21 |
|
Messages: n/a
Hébergeur: |
"Alex" <d_keyoke@hotmail.com> wrote in message news:473bf7eb$0$26761$426a74cc@news.free.fr... > "Steve" <no.one@example.com> wrote in message > news:mKH_i.34$dm.33@newsfe02.lga... >> a difference, yes. something that will make your code quit bombing and >> still get the Factory functionality...probably not. all an interface >> (IFactory in this case) is, is a contract...a definition of what *all >> usable* objects that *implement* that interface will provide a caller, >> i.e. your php code. make sense? IFactory will provide you no other >> functionality than that. here's an example in vb. > > OK it's like a class from which another inherits, then ? kind of. the difference being that there is no functionality given to a class that implements an interface (ifactory). if i inherit from a class in the traditional sense, whatever functionality is present in the parent class will be part of the inheriting class...the inheriting class can add more interfaces (functions, properties, etc.) or rewrite/override/shadow the parent class' interfaces (functions, properties, etc.) other than that, yes, they're pretty similar. > (snip the example) > >> anyway...i think i got off track, but does that you know that you're >> going to have to get at an actual Factory object in the list...which >> doesn't solve your memory problem? > > Yes, that's very ful. But it raises a question in PHP. Can I assume > that COM tells PHP what type the objects in a class (or Interface) are ? I > don't have to explicitely instanciate or cast the objects that are childs > of a COM object ? can you assume? no, not really. while COM defines everything about itself and makes that information know to any callers, php doesn't need to know any of it. php basically 'invokes' on a com object whatever you tell it to attempt. it doesn't need to know about sawMill.foo, it simply attempts to invoke 'foo' on the sawMill object. php only needs to handle errors thrown from the invocation or supply the results thereof back to the caller. > Now, I tried different values for memory_limit in php.ini and it doesnt > change anything. I had a closer look at the memory usage, and Apache also > takes almost 50M on a working page. So I'm not really sure it's a memory > problem. hmmm. glad i see in another post that you've got it figured out. i'd have focused on memory a while longer...and have gotten no where. > Actually, the COM syntax is not really complicated. So I'm beginning to > think of a bug (in the object or PHP). really? there are only a few ways to call things. what's puzzling you? > I'm considering trying a newer version of PHP. But I fear the impacts. > > Thank you very much again, things are getting clearer ![]() cheers |
|
|
|
#22 |
|
Messages: n/a
Hébergeur: |
"Csaba Gabor" <danswer@gmail.com> wrote in message news:892b2933-e964-4f5a-bbb5-f8d822f8f48b@l1g2000hsa.googlegroups.com... > Steve, thanks for your awesome exposition on VB interfaces, replete > with example. This type of post is all too rare on the web. > > Csaba wow! thanks. i'm glad it ed. cheers. > On Nov 14, 8:10 pm, "Steve" <no....@example.com> wrote: >> "Alex" <d_key...@hotmail.com> wrote in message > ... >> a difference, yes. something that will make your code quit bombing and >> still >> get the Factory functionality...probably not. all an interface (IFactory >> in >> this case) is, is a contract...a definition of what *all usable* objects >> that *implement* that interface will provide a caller, i.e. your php >> code. >> make sense? IFactory will provide you no other functionality than that. >> here's an example in vb. >> >> public interface iFactory >> public property foo as integer >> end interface >> >> public class sawMill >> implements iFactory >> public property get foo() implements iFactory.foo >> get >> return 666 >> end get >> set (byval value as integer) >> # do nothing...however, set is *required* >> # because iFactory is read/write >> end property >> public function saw() >> debug.print "sawing..." >> end function >> end class >> >> public class brewery >> implements iFactory >> private myFoo as integer >> public property get foo() implements iFactory.foo >> get >> return myFoo >> end get >> set (byval value as integer) >> myFoo = value >> end property >> public function brew() >> debug.print "brewing " & myFoo >> end function >> end class >> >> in the above, both completely unrelated classes (sawMill and brewery) >> have >> iFactory.foo as part of their definition. how they implement them is >> different, but each must have a read and write foo. >> >> if i simply say: >> >> private myFactory as iFactory >> >> and then try: >> >> myFactory.foo() >> >> it will do nothing. myFactory is an interface that has no working parts. >> however, if i do: >> >> private myFactory as iFactory = new brewery >> myFactory.foo = 15 >> >> i'll get somewhere. notice that the above works whether or not i set >> myFactory to new brewery OR sawMill. both have a foo interface. however, >> if >> i continue the above code with: >> >> myFactory.saw() >> >> it'll blow up. both saw and brew are specific interfaces defined by each >> class respectively...not by iFactory. let's say that myFactory is set >> somewhere unbeknownst to me, how would i take specific action? >> >> public function factoryToString(byval factory as iFactory, byval fooValue >> as >> integer) >> factory.foo = fooValue >> if typeof factory is sawMill then >> factory.saw() >> end if >> if typeof factory is brewery then >> factory.brew() >> end if >> end function >> >> anyway...i think i got off track, but does that you know that you're >> going to have to get at an actual Factory object in the list...which >> doesn't >> solve your memory problem? |
|