Is there anything like Python's ctype for PHP? Accessing libraries without the need to write an extension?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Python has ctypes to access libraries. In PHP you write extensions for everything. Popular extensions like the one for libgd are available almost everywhere.
Is there any extension which works like Python's ctypes, letting you access libraries without the need to write an PHP extension?
php c shared-libraries
add a comment |
Python has ctypes to access libraries. In PHP you write extensions for everything. Popular extensions like the one for libgd are available almost everywhere.
Is there any extension which works like Python's ctypes, letting you access libraries without the need to write an PHP extension?
php c shared-libraries
add a comment |
Python has ctypes to access libraries. In PHP you write extensions for everything. Popular extensions like the one for libgd are available almost everywhere.
Is there any extension which works like Python's ctypes, letting you access libraries without the need to write an PHP extension?
php c shared-libraries
Python has ctypes to access libraries. In PHP you write extensions for everything. Popular extensions like the one for libgd are available almost everywhere.
Is there any extension which works like Python's ctypes, letting you access libraries without the need to write an PHP extension?
php c shared-libraries
php c shared-libraries
edited Jan 28 '10 at 19:51
stesch
asked Jan 28 '10 at 5:53
steschstesch
6,25354161
6,25354161
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
You're looking for ffi.
3
Last release is 0.3 (alpha) 2004-01-20.
– stesch
Jan 28 '10 at 6:14
add a comment |
There is a PHP extension (irony?) called ffi. FFI stands for Foreign Function Interface, which is the generic term for when a language calls libraries written in another language.
add a comment |
I don't think there is such a thing : in PHP, the "standard" way of using a library is by writting a wrapper arround it, that exports the functions of the library to PHP.
(But maybe an extension could be written to do just what ctypes does ? -- Not sure, but maybe ^^ )
It's definately possible, though I see some pretty huge security issues here. Beginner PHP programmers aren't known to be able to control all aspects of their app (and neither does half of the experienced ones). What if someone manages to run some injected code that uses ctypes in PHP -- that includes being able to load external libraries, otherwise what's the point. All of PHP's security model (if there ever was such a thing) would be compromised.
– Tor Valamo
Jan 28 '10 at 6:02
add a comment |
I don't know of any way. But you could let SWIG build an extension for the library you want.
1
Not exactly what I had in mind. But at least I don't have to write the extension on my own.
– stesch
Jan 29 '10 at 22:22
add a comment |
PHP 7.3 will have FFI (Foreign Function Interface).
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f2152584%2fis-there-anything-like-pythons-ctype-for-php-accessing-libraries-without-the-n%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
You're looking for ffi.
3
Last release is 0.3 (alpha) 2004-01-20.
– stesch
Jan 28 '10 at 6:14
add a comment |
You're looking for ffi.
3
Last release is 0.3 (alpha) 2004-01-20.
– stesch
Jan 28 '10 at 6:14
add a comment |
You're looking for ffi.
You're looking for ffi.
answered Jan 28 '10 at 5:58
Ignacio Vazquez-AbramsIgnacio Vazquez-Abrams
595k10710821184
595k10710821184
3
Last release is 0.3 (alpha) 2004-01-20.
– stesch
Jan 28 '10 at 6:14
add a comment |
3
Last release is 0.3 (alpha) 2004-01-20.
– stesch
Jan 28 '10 at 6:14
3
3
Last release is 0.3 (alpha) 2004-01-20.
– stesch
Jan 28 '10 at 6:14
Last release is 0.3 (alpha) 2004-01-20.
– stesch
Jan 28 '10 at 6:14
add a comment |
There is a PHP extension (irony?) called ffi. FFI stands for Foreign Function Interface, which is the generic term for when a language calls libraries written in another language.
add a comment |
There is a PHP extension (irony?) called ffi. FFI stands for Foreign Function Interface, which is the generic term for when a language calls libraries written in another language.
add a comment |
There is a PHP extension (irony?) called ffi. FFI stands for Foreign Function Interface, which is the generic term for when a language calls libraries written in another language.
There is a PHP extension (irony?) called ffi. FFI stands for Foreign Function Interface, which is the generic term for when a language calls libraries written in another language.
answered Jan 28 '10 at 6:06
AnthonyAnthony
27.7k2185148
27.7k2185148
add a comment |
add a comment |
I don't think there is such a thing : in PHP, the "standard" way of using a library is by writting a wrapper arround it, that exports the functions of the library to PHP.
(But maybe an extension could be written to do just what ctypes does ? -- Not sure, but maybe ^^ )
It's definately possible, though I see some pretty huge security issues here. Beginner PHP programmers aren't known to be able to control all aspects of their app (and neither does half of the experienced ones). What if someone manages to run some injected code that uses ctypes in PHP -- that includes being able to load external libraries, otherwise what's the point. All of PHP's security model (if there ever was such a thing) would be compromised.
– Tor Valamo
Jan 28 '10 at 6:02
add a comment |
I don't think there is such a thing : in PHP, the "standard" way of using a library is by writting a wrapper arround it, that exports the functions of the library to PHP.
(But maybe an extension could be written to do just what ctypes does ? -- Not sure, but maybe ^^ )
It's definately possible, though I see some pretty huge security issues here. Beginner PHP programmers aren't known to be able to control all aspects of their app (and neither does half of the experienced ones). What if someone manages to run some injected code that uses ctypes in PHP -- that includes being able to load external libraries, otherwise what's the point. All of PHP's security model (if there ever was such a thing) would be compromised.
– Tor Valamo
Jan 28 '10 at 6:02
add a comment |
I don't think there is such a thing : in PHP, the "standard" way of using a library is by writting a wrapper arround it, that exports the functions of the library to PHP.
(But maybe an extension could be written to do just what ctypes does ? -- Not sure, but maybe ^^ )
I don't think there is such a thing : in PHP, the "standard" way of using a library is by writting a wrapper arround it, that exports the functions of the library to PHP.
(But maybe an extension could be written to do just what ctypes does ? -- Not sure, but maybe ^^ )
answered Jan 28 '10 at 5:55
Pascal MARTINPascal MARTIN
342k59590616
342k59590616
It's definately possible, though I see some pretty huge security issues here. Beginner PHP programmers aren't known to be able to control all aspects of their app (and neither does half of the experienced ones). What if someone manages to run some injected code that uses ctypes in PHP -- that includes being able to load external libraries, otherwise what's the point. All of PHP's security model (if there ever was such a thing) would be compromised.
– Tor Valamo
Jan 28 '10 at 6:02
add a comment |
It's definately possible, though I see some pretty huge security issues here. Beginner PHP programmers aren't known to be able to control all aspects of their app (and neither does half of the experienced ones). What if someone manages to run some injected code that uses ctypes in PHP -- that includes being able to load external libraries, otherwise what's the point. All of PHP's security model (if there ever was such a thing) would be compromised.
– Tor Valamo
Jan 28 '10 at 6:02
It's definately possible, though I see some pretty huge security issues here. Beginner PHP programmers aren't known to be able to control all aspects of their app (and neither does half of the experienced ones). What if someone manages to run some injected code that uses ctypes in PHP -- that includes being able to load external libraries, otherwise what's the point. All of PHP's security model (if there ever was such a thing) would be compromised.
– Tor Valamo
Jan 28 '10 at 6:02
It's definately possible, though I see some pretty huge security issues here. Beginner PHP programmers aren't known to be able to control all aspects of their app (and neither does half of the experienced ones). What if someone manages to run some injected code that uses ctypes in PHP -- that includes being able to load external libraries, otherwise what's the point. All of PHP's security model (if there ever was such a thing) would be compromised.
– Tor Valamo
Jan 28 '10 at 6:02
add a comment |
I don't know of any way. But you could let SWIG build an extension for the library you want.
1
Not exactly what I had in mind. But at least I don't have to write the extension on my own.
– stesch
Jan 29 '10 at 22:22
add a comment |
I don't know of any way. But you could let SWIG build an extension for the library you want.
1
Not exactly what I had in mind. But at least I don't have to write the extension on my own.
– stesch
Jan 29 '10 at 22:22
add a comment |
I don't know of any way. But you could let SWIG build an extension for the library you want.
I don't know of any way. But you could let SWIG build an extension for the library you want.
answered Jan 28 '10 at 17:45
user86297user86297
16214
16214
1
Not exactly what I had in mind. But at least I don't have to write the extension on my own.
– stesch
Jan 29 '10 at 22:22
add a comment |
1
Not exactly what I had in mind. But at least I don't have to write the extension on my own.
– stesch
Jan 29 '10 at 22:22
1
1
Not exactly what I had in mind. But at least I don't have to write the extension on my own.
– stesch
Jan 29 '10 at 22:22
Not exactly what I had in mind. But at least I don't have to write the extension on my own.
– stesch
Jan 29 '10 at 22:22
add a comment |
PHP 7.3 will have FFI (Foreign Function Interface).
add a comment |
PHP 7.3 will have FFI (Foreign Function Interface).
add a comment |
PHP 7.3 will have FFI (Foreign Function Interface).
PHP 7.3 will have FFI (Foreign Function Interface).
answered Nov 25 '18 at 10:50
steschstesch
6,25354161
6,25354161
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f2152584%2fis-there-anything-like-pythons-ctype-for-php-accessing-libraries-without-the-n%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown