The Letter E Posted January 16, 2011 Share Posted January 16, 2011 Hey people! I'm currently working on an free API that i will be sharing with the web community in the next few months and had a question that much of this project hinges upon: Is there a way to allow a remote include of one php file from my server? Case: I am allowing 2 ways for users to access the APi: 1. Using AJAX or cURL accessing a REST method over POST or GET (This part is already functional) 2. Allowing an include of the API Library I'm not sure if it will be completely opensource yet, only free, this is why I don't want to simply provide the source files to users. Example of what I would like to do: <?php include('http://mysite.com/myAPI/classLib.php'); ?> Anybody have a solution for that?? Thanks in advance, E Quote Link to comment https://forums.phpfreaks.com/topic/224593-remote-includes/ Share on other sites More sharing options...
dragon_sa Posted January 16, 2011 Share Posted January 16, 2011 http://www.php.net/manual/en/function.include.php This says its possible if the server including the script, not the server hosting the script, is configured to do so Quote Link to comment https://forums.phpfreaks.com/topic/224593-remote-includes/#findComment-1160184 Share on other sites More sharing options...
trq Posted January 16, 2011 Share Posted January 16, 2011 including a remote file via include or require only makes a http request for the file. this means you only actually receive the output of the included file, not the functions or variables contained within it. There is no way to do this without users actually downloading code that you provide.. Quote Link to comment https://forums.phpfreaks.com/topic/224593-remote-includes/#findComment-1160198 Share on other sites More sharing options...
dragon_sa Posted January 16, 2011 Share Posted January 16, 2011 if your looking to maintain an updated version of this file you can put it on the server that needs to include it, then have a cron job on your server upload newer versions of the file to the remote server, so you need only update the file on your server Quote Link to comment https://forums.phpfreaks.com/topic/224593-remote-includes/#findComment-1160214 Share on other sites More sharing options...
trq Posted January 16, 2011 Share Posted January 16, 2011 if your looking to maintain an updated version of this file you can put it on the server that needs to include it, then have a cron job on your server upload newer versions of the file to the remote server, so you need only update the file on your server I think you might have misread the ops question. Quote Link to comment https://forums.phpfreaks.com/topic/224593-remote-includes/#findComment-1160228 Share on other sites More sharing options...
The Letter E Posted January 17, 2011 Author Share Posted January 17, 2011 including a remote file via include or require only makes a http request for the file. this means you only actually receive the output of the included file, not the functions or variables contained within it. There is no way to do this without users actually downloading code that you provide.. That's what I thought. looks like I'll just stick to the REST Api and probably add a SOAP server later. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/224593-remote-includes/#findComment-1160576 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.