Jump to content

logansama

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

About logansama

  • Birthday 03/01/1982

Contact Methods

  • Website URL
    http://

Profile Information

  • Gender
    Not Telling
  • Location
    City of Pretoria, Gauteng Province, South Africa. In the office

logansama's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the input. Already started googling the apache bench you mentioned. What i have done as an attempt to "think out the php box" so to speak, is to write a linux script which will manage the starting of many individual "sessions" (each with unique PID) which will each then run the script, providing their independent details. Doing further testing to see if it will work, but like i said, will read up on the apache bench. Thank you.
  2. Good day, Never dealt with creating automated bots (in php or in any other language) and i dont have experience in stress testing php. But my boss says i must work it out. I have a script which plays a game in itself and stores data in a table. I require to run about 1milion games to check if the maths work out the way they should (gambling maths etc). Php is not that capable to run multiple instances/threads of the script without having grave issues with data access from the tables etc. Was told to look into building a script (php) which would create large volumes of "bot" players which would individually (separate from any other bot created) run the script (thus run a game each). The final result will be many "simultaneous" games played which will result in reaching (hopefully) the 1milion mark rather quickly! Like i said i have no experience in this, but i have a few ideas i am starting on. Any input or tips on where to start looking into this matter would be greatly appreciated. Any experience you wish to share as well! Thank you.
  3. hehe, yes i will be given pre-written c++ to turn into an extension this way. My level of skill with C and C++ is entry-level at best. But yes, since php extensions should be written in C i fully agree with you.
  4. Last night i managed to get something going. Its basic, maybe not exactly 100% correct, but it works and is a good starting point. Please note that i still created the extension using Swig. Also note that the C++ i used was based on tutorial examples i could find, i am not a c++ programmer. To provide the data and steps: 1.) The Input file :: test4.i %module test4 %{ #include "test4.cpp" %} %include "test4.cpp" This file describes what you want to include. I always had the file.h descriptions here, but that caused a fault when a function was called from the php. The reason was that the function is listed in the extension but the implementation does not exist. By listing the cpp file (implementation) the function calls result correctly in the php. 2.) test4.h #ifndef __TEST4_H__ #define __TEST4_H__ int test4_showNumber(); #endif 3.) test4.cpp #include <iostream> #include "test4.h" using namespace std; int test4_showNumber() { int num = 8 +12; return num; } Please note this is VERY simple, the point was just to test actual implementation. I did everything in Ubuntu 8.10. In order to use swig you need to have it installed. View their website for more details on everything they do. http://www.swig.org. You also need a working PHP installed. I used XAMPP for linux (lampp) as well as a version compiled from source. v5.2.8 PHP in both cases. And lastly a working gcc/g++ installation. I used version 4.3.2. In the directory where the three above files are located i ran the following commands: 1.) swig -php5 -c++ test4.i this builds a few files. Their uses can be read about on their site. 2.) g++ 'php-config --includes' -fpic -c test4_wrap.cpp Please note that i did not type 'php-config --includes' as part of the command. What i mean by it is that the output you get from the command 'php-config --includes' should be added in the command above in its place. The lampp installation did not have the needed include directories and files, so i used those from the source built php. 3.) g++ -shared test4_wrap.o -o test4.so Then copy the .so file to where your extensions are stored. In my case with lampp it was in ../lampp/lib/php/extension/no-debug-non-zts-20060613/. Then edit your php.ini file: Add the following under "Dynamic Extensions": extension=test4.so Then restart your apache so that the new settings of the php.ini is loaded. The test php file i created was as follows: <?PHP if( extension_loaded("test4") ) { echo "<br><br><br>LOADED TEST 4 !! <br>"; } else { echo "NOTHING!! <br>"; } if (function_exists('test4_showNumber')) { echo "test4_showNumber is available.<br />\n"; } else { echo "test2_testNumber not available.<br />\n"; } echo "<br>The number is ....<br>"; $val1= test4_showNumber(); echo $val1; the output is then: LOADED TEST 4 !! test4_showNumber is available. The number is .... 20 Like i said a very simple implementation, but still an implementation and a start. Thank you for all the help everybody and hope someone finds this helpful/interesting.
  5. Some additional findings: (and with these i find myself in waters i have not swam in before. ) ran "php --re test" ('test' being the name of the extension i created using the Swig environment): Extension [ <persistent> extension #55 test version <no_version> ] { - Functions { Function [ <internal:test> function new_test ] { } Function [ <internal:test> function test_calc ] { } Function [ <internal:test> function test_getnumber ] { } } } test_calc is implemented in the original cpp file to receive two int parameters. so when i call itin a php file as follows: <?PHP test_calc(10,10); i get the following: Warning: Wrong parameter count for test_getnumber() in /opt/lampp/htdocs/extension/calculate.php on line 6 the test_getnumber() is supposed to receive no parameters but when i call test_getnumber() i get the same warning as above. At this point i am not even sure what to ask help for? hehe I think i will settle for ANY input or opinions etc. Thank you.
  6. Swig does the 'wrapping' of your source/implementation code before you proceed to compile it into a shared object. Normal extensions are in C so you need some extra conversion if you are using C++. Swig apparently does all the needed changes for you. I just need to figure out exactly how so i can actually use the extension. A link if you want more detail http://www.swig.org/Doc1.3/Php.html#Php_nn2_6 it also deals with many other langiages, not just php and c++.
  7. by all means i am sure that the extension has not been configured as part of php. I am not sure if the extension shared-object does contain a fault. Is there a means to test it? The shared object is created by compiling a wrapped .cpp file. This wrapped .cpp file is created by Swig using a normal .cpp file with c++ code. This wrapped cpp file contains the needed php/zend/cpp/c converted code used by php to understand extension. The original cpp file has the function foo(), the wrapped cpp file (before compiling) has the function as _wrap_foo() and the EXAMPLE php file the Swig created (to test the shared object extension) has a call to _foo(). In my test php file i have made a call to foo(), _wrap_foo() and _foo() and all of them result in "call to undefined function". I am now trying to figure out what the extension contains, wonder if there is a standard way to view the content of a loaded extension?
  8. Good day, Attempting the way of dynamically loading a created extension (.so) via the php.ini on linux. The extension is a c++ based extension created using Swig framework. I understand the php.ini way being: (for explaining purposes 'extension.so' represents the extension file/s ) 1. copy the extension.so file to be used, to the extensions dir/location specified by the the php.ini file 2. add to the php.ini file (under Dynamic Extensions) the line "extension=extension.so" 3. Restart the apache to reload the new settings of the php.ini. 4. Call the functions in a php file to test. unfortunately i receive errors when calling the function: "Fatal error: Call to undefined function foo() in /file_location/file.php on line #" when testing by adding the following code to top of php file....: (please note that enable_dl is On in the php.ini) if( dl('extension.so') ) { echo "could load all good! <br>"; } ..i recieve the output: ""Warning: Module 'extension' already loaded in Unknown on line 0"" i understand the above to mean that dl is trying to load something that is already loaded. i also did a command line check 'php -m' to check that the 'test' extension i am dynamically loading has not been compiled in with php. And it has not been. I am not sure if this all means the extension has loaded correctly but its been created incorrectly, or if the shared object has just not been loaded correctly. If anyone knows that my php.ini implementation is flawed, please tell me and if possible also on how to do it correctly. If you know of another way to do dynamically add extension library files, please help me out. I thank you in advance.
  9. If you get the .cpp and header file's structure correct and specify correct php include files then the Swig framework compiles correctly without error. Seems to do all correctly. Now i just need to work out how the hell to correctly load the generated .so file for use in php!
  10. An engine for a project has already been created using c++ and it would be the death of the developer if he would be told to redo it in C. what exactly has been done in the c++ code i am not wholly aware of. I have been given a link to a script called Swig which does allow you to create a suitable wrapper of your cpp code. Does most of the code adapting and macro replacing stuff for you. Then you just compile the wrapped code into a library (.so) and use that in php. Problem is that this script requires a list of includes from php and i cannot figure out how to provide the includes. Swig tut: http://www.swig.org/Doc1.3/Php.html#Php_nn2_6
  11. Ok, i have just been informed that i must focus my attention on how to build a PHP extension in linux using external libraries (.so). Thus using the PHP_ARG_WITH in the config.m4 file. My linux box is estimated to arrive in 1 hour. Will try and test then. Any input about the external library version would be greatly appreciated.
  12. 1st: From teh sticky it seems people are strict about what is allowed here, but from what i can define this is best place to have this post - if not, indicate where and i will move the post. I have not personally built php extensions but i have studied the process it goes through. I was instructed to determine (for a project i have just been thrown into) if it is at all possible to build php extensions using either external .so (built form c++ files) or actually using c++ (cpp) files as implementation(s) instead of C files? So far from all the "well explained" tutorials i have found that the default files generated by calling the ext_skel is basically for C code. But like i said we have c++ code we would like to build the extension implementations with. What i have determined so far: 1) One can apparently use PHP_ARG_WITH in the config.m4 which will allow you to specify an external .so file when calling 'configure'. But how this would effect other files in the skel setup i am not aware of. For example: does that mean the default C implementation file is left as is? 2) through online examples i have found that apparently cpp files may be used: http://www.mail-archive.com/internals@lists.php.net/msg24298.html resolved on last reply http://cvs.php.net/viewvc.cgi/pecl/rar/config.m4?revision=1.6&view=markup For all purposes i hope to test out the above to points today, but i must wait for my station to be loaded with linux later this morning before i can try. All i ask for is some input from those who have knowledge in this area, and perhaps a nudge into the right direction of testing/research. Thank you.
  13. Good day gents and gentets! I just wanted to ask the opinion of others on the following: When recieveing values, usually through $_POST or $_GET one would determain if a value was actually received by doing a isset(..) on the value element or just the whole array. But would you aggree or disagree that it would be good practice to also have a empty(..) check on the same value? I have had incidents where the value/variable etc received was set but happened to be empty. I wonder if i should make it a required practice to always do both a isset() and empty()? your input will be values!
  14. It appears there is some serious problems with IE7 and it handling of sessions, cookies etc. Even Microsoft isn't giving much info on how to work around the issue but seem to kind-off indicate they are aware of it! So now i develop in-house for FF and the other browsers, no longer will i bother to make the code IE compatible! YAY!!
  15. <damned my inability to get on forums enough!! - cant for the life of me remember how to edit original post - if even possible> Did some additional testing on sessions in the page. There are basically three key areas where data is passed to and fro between php and interface. I decided to use session_id() to view the id of the session at each of these three "steps". In firefox all three the session_id's echoed was the same. No difference. And code works fine! In IE7 each of the three echoed session id's are different!! I do not have in depth knowledge of php SESSIONS etc but i do believe my problem will be solved by getting IE NOT to 'reset' the session at every step (even though i am not sure why it resets as i don't use new windows/tabs??). Now to try this, but please if this additional info helps, please provide any help where you can! Thank You, David
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.