Results 1 to 6 of 6

Thread: [Solved] Including external php libraries in lianja apps

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    3

    [Solved] Including external php libraries in lianja apps

    Dear Sir,

    How to include external php libraries such as mpdf in lianja and use them in lianja. Kindly explain with example code.

    Kind Regards,

    Kandarp Mistry.
    Last edited by barrymavin; 2014-12-23 at 21:44.

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,817
    In the same way you would do it normal PHP code.

    Copy your PHP library into either the app directory (use drag and drop) or the library directory, then reference it using require() in the code for your PHP webview section.

    Code:
    <html>
    <body>
    <?php
        require("mylib.php"); 
        echo "Hello world"; 
    ?>
    </body>
    </html>
    and then mylib.php contains:

    Code:
    <html>
    <body>
    <?php
        echo "Hello world from mylib</br>";
    ?>
    </body>
    </html>
    and the result is:

    Name:  Screen Shot 2014-10-06 at 12.19.40 PM.jpg
Views: 315
Size:  62.2 KB
    Last edited by barrymavin; 2014-10-06 at 00:22.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,817
    Also note that on windows the php.ini file is in:

    c:\Lianja\scriptinglanguages\php\conf\php.ini

    You can edit the include_path to include directories containing your PHP libraries or else add ..\library\ to the include_path so that require() will look in the Lianja library directory as well as the App directory.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Junior Member
    Join Date
    Sep 2014
    Posts
    3
    Dear Sir,

    I have included the mpdf library as instructed in my app directory as well as library directory. I have typed the following sample code

    $page1_section8_section = Lianja::createObject("Section");
    include("MPDF54\mpdf\mpdf.php");
    $mpdf=new mPDF();
    $mpdf->WriteHTML('<p>Hallo World</p>');
    $mpdf->Output();
    $returnvalue = $page1_section8_section;

    in the custom php section.

    but in the pages view i am getting the following error : "Error - mPDF requires mb_string functions. Ensure that PHP is compiled with php_mbstring.dll enabled."

    I have checked in the php.ini that php mbstring extension is enabled but it still shows the above error. Kindly help.

    Regards,

    Kandarp Mistry.

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,817
    If all you want to do is generate a PDF file, do you realize that any HTML that is formatted in a WebView can be saved as a PDF file? This is all built-in.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Junior Member
    Join Date
    Sep 2014
    Posts
    3
    Dear Sir,

    Thank you for that information.

    Regards,

    Kandarp Mistry.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us