4 Replies Latest reply on Feb 7, 2016 5:20 AM by mikebeargie

    How to track php requests

    njem

      I have to oversee sorting out some issues between a php web page from one developer and the FM data it accesses from another developer. I'm looking for a way to track what the php is actually requesting, what the Find criteria are, what bunch of records are then returned and transmitted to the php, etc. I think the php code is accidentally asking for much too broad of Find and then it takes a long time for all those records to get transmitted back to the web page. I can read the php but am not expert and there are a lot of variables which means it would be easier and more sure to just see what actually ends up getting requested. The FM is hosted by a hosting company who will cooperate some on this but it's not like a server I run and can do anything I want in the server. Our files that they host are entirely under our control and we could do anything we want in them. If every php request was in the form of calling a script then I could put in the scripts to log what they're doing but that would be a massive rewrite of the php. Any ideas that would help sort this out?

       

      Thanks.

        • 1. Re: How to track php requests
          mikebeargie

          Not really a way to log something that fine without writing the PHP to do so.

           

          Although it should be relatively easy on the CWP side to just write a record to a logs table using the existing variables.

           

          PHP has a handy function called get_defined_vars();

          PHP: get_defined_vars - Manual

           

          Basically, if you dump the contents of that function to a record in filemaker, you'll have a simple log.

           

          The CWP would look pretty simple, like this:

          $vars = get_defined_vars();

          $record = $fm->newAddCommand('YourLogLayout');

          $record->setField('logField', $vars);

          $result = $record->execute();

          This would create a new record in your log table, in a "logField" field, using a "YourLogLayout" layout in filemaker. Since you're already doing the find, you're already connecting to filemaker (note you might need to update $fm-> with the name of the object you created as your FM connection).

           

          That might be an easy starting point for you at least. Although if you were able to post your code here, then maybe we could tell you if it's too broad. Chances are it might just be your host that's slow. CWP has always been relatively fast, even returning large data sets. Network lag and server hardware can have an effect on that, and since you've already admitted to using shared hosting, I'm wary to make a suggestion without seeing your code.

          • 2. Re: How to track php requests
            njem

            Mike, thanks. I may give that code snippet a try. I was afraid of that, that there is no way to track what finds are requested or what data gets sent back without modifying the php. Too bad FM doesn't give a way to do that.

            • 3. Re: How to track php requests
              tcfitzgerald

              What version of FileMaker Server are you using?  I know in 12-14 (I'm guessing this was in earlier versions, but I can't recall at the moment) you can log the Web Publishing requests by turning on Web Publishing logging in the Admin console.  This creates a file called "wpe.log" in the Logs folder of your Web Publishing server. This log can contain the requests passed through the XML interface (which I believe the PHP API uses), including the parameters of the requests.

              • 4. Re: How to track php requests
                mikebeargie

                It's kind of ridiculous to expect that filemaker would have that level of logging for Custom Web Publishing. Just like how in filemaker, you would need to script to go to a log table and create a record of your find request, it's even MORE true in CWP. The PHP is fairly simple, so don't casually write off FM as "too bad it doesn't do ___" because you don't have a full understanding of the code you're trying to augment. If it's mission-critical, then you should hire a consultant that can do the PHP work for you to get you what you need.