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;
}







7















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?










share|improve this question































    7















    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?










    share|improve this question



























      7












      7








      7


      1






      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?










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 28 '10 at 19:51







      stesch

















      asked Jan 28 '10 at 5:53









      steschstesch

      6,25354161




      6,25354161
























          5 Answers
          5






          active

          oldest

          votes


















          2














          You're looking for ffi.






          share|improve this answer



















          • 3





            Last release is 0.3 (alpha) 2004-01-20.

            – stesch
            Jan 28 '10 at 6:14



















          1














          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.






          share|improve this answer































            0














            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 ^^ )






            share|improve this answer
























            • 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



















            0





            +100









            I don't know of any way. But you could let SWIG build an extension for the library you want.






            share|improve this answer



















            • 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



















            0














            PHP 7.3 will have FFI (Foreign Function Interface).






            share|improve this answer
























              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
              });


              }
              });














              draft saved

              draft discarded


















              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









              2














              You're looking for ffi.






              share|improve this answer



















              • 3





                Last release is 0.3 (alpha) 2004-01-20.

                – stesch
                Jan 28 '10 at 6:14
















              2














              You're looking for ffi.






              share|improve this answer



















              • 3





                Last release is 0.3 (alpha) 2004-01-20.

                – stesch
                Jan 28 '10 at 6:14














              2












              2








              2







              You're looking for ffi.






              share|improve this answer













              You're looking for ffi.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              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














              • 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













              1














              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.






              share|improve this answer




























                1














                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.






                share|improve this answer


























                  1












                  1








                  1







                  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.






                  share|improve this answer













                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 28 '10 at 6:06









                  AnthonyAnthony

                  27.7k2185148




                  27.7k2185148























                      0














                      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 ^^ )






                      share|improve this answer
























                      • 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
















                      0














                      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 ^^ )






                      share|improve this answer
























                      • 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














                      0












                      0








                      0







                      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 ^^ )






                      share|improve this answer













                      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 ^^ )







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      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



















                      • 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











                      0





                      +100









                      I don't know of any way. But you could let SWIG build an extension for the library you want.






                      share|improve this answer



















                      • 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
















                      0





                      +100









                      I don't know of any way. But you could let SWIG build an extension for the library you want.






                      share|improve this answer



















                      • 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














                      0





                      +100







                      0





                      +100



                      0




                      +100





                      I don't know of any way. But you could let SWIG build an extension for the library you want.






                      share|improve this answer













                      I don't know of any way. But you could let SWIG build an extension for the library you want.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      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














                      • 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











                      0














                      PHP 7.3 will have FFI (Foreign Function Interface).






                      share|improve this answer




























                        0














                        PHP 7.3 will have FFI (Foreign Function Interface).






                        share|improve this answer


























                          0












                          0








                          0







                          PHP 7.3 will have FFI (Foreign Function Interface).






                          share|improve this answer













                          PHP 7.3 will have FFI (Foreign Function Interface).







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 25 '18 at 10:50









                          steschstesch

                          6,25354161




                          6,25354161






























                              draft saved

                              draft discarded




















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              這個網誌中的熱門文章

                              Hercules Kyvelos

                              Tangent Lines Diagram Along Smooth Curve

                              Yusuf al-Mu'taman ibn Hud