PDA

View Full Version : [Solved] Including external php libraries in lianja apps



kandarpmistry
2014-10-05, 01:48
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.

barrymavin
2014-10-06, 00:20
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.



<html>
<body>
<?php
require("mylib.php");
echo "Hello world";
?>
</body>
</html>


and then mylib.php contains:



<html>
<body>
<?php
echo "Hello world from mylib</br>";
?>
</body>
</html>


and the result is:

787

barrymavin
2014-10-06, 00:33
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.

kandarpmistry
2014-10-06, 08:18
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.

barrymavin
2014-10-06, 08:37
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.

kandarpmistry
2014-10-07, 05:13
Dear Sir,

Thank you for that information.

Regards,

Kandarp Mistry.