# documentation of php5ts.dll and .NET wrapper

- Thread: https://externals.io/message/30208
- Original archive: https://news-web.php.net/php.internals/30208
- Started by muquaddim on 2007-06-17T15:56:09+00:00
- Messages: 14
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #30208 — muquaddim — 2007-06-17T15:56:09+00:00

URL: https://externals.io/message/30208#30208

Hi,
I have use dumpbin to get the method names of php5ts.dll file. I get many 
names.
2 of these methods are,
"php_execute_script"
"php_execute_simple_script"

I guess these are the methods that are responsible for executing php source 
(.php) files.
now I need to know, what are the parameter of these methods. How can I get 
the documenttation on parameters.
If I get this I could have make a .NET wrapper.
Thanks

---

## #30209 — Tijnema — 2007-06-17T16:05:39+00:00

URL: https://externals.io/message/30208#30209 · In reply to: #30208

> Hi,
> I have use dumpbin to get the method names of php5ts.dll file. I get many
> names.
> 2 of these methods are,
> "php_execute_script"
> "php_execute_simple_script"
>
> I guess these are the methods that are responsible for executing php source
> (.php) files.
> now I need to know, what are the parameter of these methods. How can I get
> the documenttation on parameters.
> If I get this I could have make a .NET wrapper.
> Thanks

Just take a look at the PHP Source code, the functions are well
described there... :)

Tijnema

---

## #30210 — johannes@schlueters.de — 2007-06-17T16:33:26+00:00

URL: https://externals.io/message/30208#30210 · In reply to: #30208

Hi muquaddim,

before calling these API functions you have to initialise some data
structures. The usual way to embed PHP into another environment is to
provide an SAPI module which wraps PHP's APIs to something you can use
from another system in a nice way.

See php-src/sapi/embed/ for a quite simple SAPI module, and Sara's book
(ISBN-10: 067232704X, ISBN-13: 978-0672327049) as a reference.

johannes


> Hi,
> I have use dumpbin to get the method names of php5ts.dll file. I get many 
> names.
> 2 of these methods are,
> "php_execute_script"
> "php_execute_simple_script"
> 
> I guess these are the methods that are responsible for executing php source 
> (.php) files.
> now I need to know, what are the parameter of these methods. How can I get 
> the documenttation on parameters.
> If I get this I could have make a .NET wrapper.
> Thanks

---

## #30211 — muquaddim — 2007-06-17T16:42:51+00:00

URL: https://externals.io/message/30208#30211 · In reply to: #30209

"Tijnema" <tijnema@gmail.com> wrote in message 
news:d8269d910706170905h7c53fbd4sec26625dfaceda0b@mail.gmail.com...
> 
> > […]
>
> Just take a look at the PHP Source code, the functions are well
> described there... :)
>
> Tijnema
Yes I have been watching the source for long time. But no hope. There is no 
comments on the source.
In the /main/main.c file I found this,
PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
here TSRMLS_DC  is defined in /Zend/zend_language_scanner.c file as
-------------------------------------------------------------
#ifdef ZTS
#define TSRMLS_D void ***tsrm_ls
#define TSRMLS_DC , TSRMLS_D
#define TSRMLS_C tsrm_ls
#define TSRMLS_CC , TSRMLS_C
#else
#define TSRMLS_D
#define TSRMLS_DC
#define TSRMLS_C
#define TSRMLS_CC
#endif
-------------------------------------------------------------
this is contitional compilation. thats why I dont' know where the 
php_execute_script method int php5ts.dll has the last parameter.
I think you understand.
The main problem with the last parameter

---

## #30212 — Tijnema — 2007-06-17T17:08:58+00:00

URL: https://externals.io/message/30208#30212 · In reply to: #30211

>
> "Tijnema" <tijnema@gmail.com> wrote in message
> news:d8269d910706170905h7c53fbd4sec26625dfaceda0b@mail.gmail.com...
> > […]
> Yes I have been watching the source for long time. But no hope. There is no
> comments on the source.
> In the /main/main.c file I found this,
> PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
> here TSRMLS_DC  is defined in /Zend/zend_language_scanner.c file as
> -------------------------------------------------------------
> #ifdef ZTS
> #define TSRMLS_D void ***tsrm_ls
> #define TSRMLS_DC , TSRMLS_D
> #define TSRMLS_C tsrm_ls
> #define TSRMLS_CC , TSRMLS_C
> #else
> #define TSRMLS_D
> #define TSRMLS_DC
> #define TSRMLS_C
> #define TSRMLS_CC
> #endif
> -------------------------------------------------------------
> this is contitional compilation. thats why I dont' know where the
> php_execute_script method int php5ts.dll has the last parameter.
> I think you understand.
> The main problem with the last parameter

Well, that has something to do with Maintainer ZTS mode, I don't study
on PHP source myself, but php_execute_script requires a file handle,
so you should open one first. (With some zend function...)
Like Johannes said, take a look at other SAPI's, as there's usefull
information in too...

Tijnema

---

## #30213 — Wez Furlong — 2007-06-17T22:42:55+00:00

URL: https://externals.io/message/30208#30213 · In reply to: #30208

> If I get this I could have make a .NET wrapper.

You may also want to look at this:

  http://netevil.org/blog/2004/jul/phpscript

source code:

  http://cvs.php.net/viewvc.cgi/pecl/activescript/

--Wez.

---

## #30233 — muquaddim — 2007-06-18T22:12:29+00:00

URL: https://externals.io/message/30208#30233 · In reply to: #30208

I think the configure option "--disable-zts" will work on the following 
lines.

#ifdef ZTS
#define TSRMLS_D void ***tsrm_ls
#define TSRMLS_DC , TSRMLS_D
#define TSRMLS_C tsrm_ls
#define TSRMLS_CC , TSRMLS_C
#else
#define TSRMLS_D
#define TSRMLS_DC
#define TSRMLS_C
#define TSRMLS_CC

In that case my function definition will be easily understandable as I don't 
understand the TSRMLS_DC part.
I am planning to call the php5nsapi.dll entry points. those were most easy 
for me.
Just tell me someone, Is it the right way?

---

## #30237 — johannes@schlueters.de — 2007-06-19T07:47:36+00:00

URL: https://externals.io/message/30208#30237 · In reply to: #30233

Hi again,


> I think the configure option "--disable-zts" will work on the following 
> lines.
> 
> #ifdef ZTS
> #define TSRMLS_D void ***tsrm_ls
> #define TSRMLS_DC , TSRMLS_D
> #define TSRMLS_C tsrm_ls
> #define TSRMLS_CC , TSRMLS_C
> #else
> #define TSRMLS_D
> #define TSRMLS_DC
> #define TSRMLS_C
> #define TSRMLS_CC
> 
> In that case my function definition will be easily understandable as I don't 
> understand the TSRMLS_DC part.

Sara has a nice article about TSRM:
http://blog.libssh2.org/index.php?/archives/22-What-the-heck-is-TSRMLS_CC-anyway.html and since you're using php5ts.dll you have zts enabled.

> I am planning to call the php5nsapi.dll entry points. those were most easy 
> for me.
> Just tell me someone, Is it the right way?

When using php5nsapi.dll you're application has to offer the nsapi stuff
PHP uses then.

As said in my last post: The best is to build a custom SAPI which fit's
your need. I mentioned sapi/embed, Wez had a few suggestions about
activescript.

Just calling some random API functions will most likely not work, you
should first write a (small) sapi in C giving you the API you need for
your needs.

johannes

---

## #30242 — Richard Quadling — 2007-06-19T08:38:26+00:00

URL: https://externals.io/message/30208#30242 · In reply to: #30237

> Sara has a nice article about TSRM:
> http://blog.libssh2.org/index.php?/archives/22-What-the-heck-is-TSRMLS_CC-anyway.html and since you're using php5ts.dll you have zts enabled.

Why have ...

TSRMLS_CC

when ...

, TSRMLS_C

actually looks more "correct" when you're reading the code ...

php_myextension_globals_ctor(&myextension_globals TSRMLS_CC);

vs

php_myextension_globals_ctor(&myextension_globals , TSRMLS_C);


I'm not saying change anything, but from someone trying to make
headway with the source, it just looks right (parameters are separated
by a comma not a space).


-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

---

## #30243 — Stut — 2007-06-19T08:42:23+00:00

URL: https://externals.io/message/30208#30243 · In reply to: #30242

Richard Quadling wrote:
> 
> > […]
> 
> Why have ...
> 
> TSRMLS_CC
> 
> when ...
> 
> , TSRMLS_C
> 
> actually looks more "correct" when you're reading the code ...
> 
> php_myextension_globals_ctor(&myextension_globals TSRMLS_CC);
> 
> vs
> 
> php_myextension_globals_ctor(&myextension_globals , TSRMLS_C);
> 
> 
> I'm not saying change anything, but from someone trying to make
> headway with the source, it just looks right (parameters are separated
> by a comma not a space).

Because those macros may be defined as empty, meaning you'd be trying to 
compile...

php_myextension_globals_ctor(&myextension_globals , );

...which the compiler is not gonna like at all.

-Stut

-- 
http://stut.net/

---

## #30244 — Gwynne Raskind — 2007-06-19T08:44:06+00:00

URL: https://externals.io/message/30208#30244 · In reply to: #30242

> > […]
> Why have ...
>
> TSRMLS_CC
>
> when ...
>
> , TSRMLS_C
>
> actually looks more "correct" when you're reading the code ...
>
> php_myextension_globals_ctor(&myextension_globals TSRMLS_CC);
>
> vs
>
> php_myextension_globals_ctor(&myextension_globals , TSRMLS_C);
>
>
> I'm not saying change anything, but from someone trying to make
> headway with the source, it just looks right (parameters are separated
> by a comma not a space).

Because with ZTS off, this would result in:

php_myextension_globals_ctor(&myextension_globals, );

Which would be a syntax error.

-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."

---

## #30254 — muquaddim — 2007-06-19T15:03:30+00:00

URL: https://externals.io/message/30208#30254 · In reply to: #30237

So I have to write my own Sapi module in PHP way :-(
It looks like too tough for me. And its the right way.
My intention is to implement a simple funcion

int execute(char *filename); //filename is a php file

For I have to write a sapi module. No matter I'll at least try it.
Now the big question.
Can anyone tell me how to write sapi modules for php
I have googled for long time but no hope.
I have seen that the directories and the sourc file in the sapi directory
has a special format.
May be this is the format of SAPI module. It would be great if there is any
example.
sapi/example perhaps.
Lastly about Sara's book. I have to buy it. This is what I cant.
Please show me way.

---

## #30348 — Richard Lynch — 2007-06-28T20:14:42+00:00

URL: https://externals.io/message/30208#30348 · In reply to: #30242

> 
> > […]
>
> Why have ...
>
> TSRMLS_CC
>
> when ...
>
> , TSRMLS_C
>
> actually looks more "correct" when you're reading the code ...
>
> php_myextension_globals_ctor(&myextension_globals TSRMLS_CC);
>
> vs
>
> php_myextension_globals_ctor(&myextension_globals , TSRMLS_C);
>
>
> I'm not saying change anything, but from someone trying to make
> headway with the source, it just looks right (parameters are separated
> by a comma not a space).

So, when would it ever be "right" to use the _C version?

Someplace where the code is completely meaningless in a non-ZTS
environment only?...

That seems kind of an awful lot of meta-knowledge to have to carry
around in one's head...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

---

## #30350 — Stanislav Malyshev — 2007-06-28T20:26:39+00:00

URL: https://externals.io/message/30208#30350 · In reply to: #30348

> So, when would it ever be "right" to use the _C version?

When you have function that its one (possible) argument is TRSM pointer.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com
