No announcement yet.

Include class library

  • Filter
  • Time
  • Show
Clear All
new posts

  • Include class library

    Hi all

    i'm trying to use a 3rd party library with classes
    Normally i've to create a test.php file with the following code
    echo 'start process<br>';
    require_once ('/var/www/spcdev/SpcEngine.php');
    echo 'loading array<br>';
    $user = array('username' => 'usertest', 'email' => '');
    echo 'create user<br>';
    echo 'end<br>';
    and in this way everything is running well thru the command php -f test.php.

    But if i use the same code inside a blank application on the onExecute event, then nothing seems to run: just the first message is showed and that's all. No errors and no warning.

    Someome have an idea?

    Thank in advance.
    Giorgio Bravi
    Dolphin Software & Thinkware

  • #2
    I hope the path is correct and is allowed from the webserver process, and thatit has the proper rights.. Anyway why dont you put a try catch except around it then you can find out what happens yourself.


    • #3
      Thank you fo the suggestion but seems the problem is on the "include" statement.
      echo "start<br>";
      $file_include = '/var/www/spcdev/SpcEngine.php';
      echo "test ".$file_include."<br>";
      if(file_exists( $file_include )){
      echo "test ok ".$file_include."<br>";
      include( $file_include );
      echo "included <br>";
      $user = array('username' => 'user3', 'email' => '');
      echo "array loaded <br>";

      echo "done <br>";
      else {
      echo"Function file does not exist";
      And the program end at include statement. This is the ouput
      test /var/www/spcdev/SpcEngine.php
      test ok /var/www/spcdev/SpcEngine.php
      No idea...
      Giorgio Bravi
      Dolphin Software & Thinkware


      • #4
        odd I thought include would produce and warning and continue the script.. Hang a try catch around it to see the error.. That should help you further.


        • #5
          Hi. I have been able to put the code from an external php file into one of the SC libraries, then in my blank app's onExecute event use include and it all works. I would try that appoach.

          1. go to Tools - Libraries - set to project - then upload the php file

          2. in your app, go to programming - libraries - check the box next to your new file

          3. in the blank app onExecute event:

          require_once 'Blablah.php';
          $myBlah = new Blah_Blah;

          Note that the path is just the file as named in the Library. SC handles where that is actually stored I guess. The above definitely works for me - hope it helps


          • #6
            Many tanks to all!!!

            The tip about including in libraries make all easy and running now!

            Another problem i've found is: if the include file don't have the final "?>" then everything goes wrong !!!! that's also my case and no warnings at all

            Have a nice day!!
            Giorgio Bravi
            Dolphin Software & Thinkware