Results 1 to 4 of 4

Thread: [Answers] PHP

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] PHP

    Q:
    How to include external php libraries such as mpdf
    A:
    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:



    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.



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2017-01-02 at 03:41.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    I am talking server-side. For PHP in Lianja I would use something like:

    Code:
    rs = db->openRecordset("select * from mytable")
    but I don't see where to pass in the arguments, in like regular php it works like this:

    Code:
    $sql  = 'select * from clients where clientid = ?';
    $data = array(53);
    
    $res =& $db->query($sql, $data);
    A:
    Well openRecordSet() does not support parameter markers. It's not the same as query() which is included in from an external PHP library or extension (possibly PDO).
    Just build up the character variable and give it as the argument to openRecordSet().



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2017-01-02 at 03:40.

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    I wold like to know if php can be used for web application because i tried an example and go the message that the scripting language must be java script.
    So it seems that Php scripting is used for desktop development. can someone confirm this? I'm using lianja 3.0
    A:
    The client code for web and/or mobile apps needs to be JavaScript.
    A2:
    Have a look at this video I created a little while ago.

    https://www.youtube.com/watch?v=_FhVyBtcWjM

    It shows how you can call client side code. I was using Foxpro, but I believe you can do the same thing with php.
    You can use the
    standard sections to build the front end, then use you back end calls to php.

    Also - have a look at virtual tables. I use SQL Server often as my backend and Lianja handles it very well.



    Q:
    I have no idea where to put lianja code vs where to put the PHP code, and what are the limit of these codes.
    For example, I tried putting echo 'hello world' (simple PHP) and see how that would affect a section / gadget, but I don't see hello world displayed anywhere in any section / gadget. So is there a limitation on the PHP codes I can write? How do they integrate into Lianja code base and the UI components?

    A:
    PHP is just fine and stick with it in delegates as you are comfortable with it. For example I am VFP developer and now javascript does not seems so strange to me.

    For beginning I would suggest you make copy of apps folder. Then open some demo app written in PHP and insert your code somewhere, run to see what happened.
    Where you can find demo in "your" language? This link might help (not so outdated):
    http://www.lianja.com/community/show...ipting-languag

    Lianja is datacentric. You want to make an application which will show your tables in some relation, so your end user will Create new records/rows, Read it, Update and Delete (CRUD).
    Thinking that
    abstract way: you drag tables (sections) and define relations visually. These are Standard sections which are responsible for all CRUD and are doing this automatically.

    Second way is Custom section. Here you write more code in your language according object hierarchy (same for all languages). Lianja is live, connected to data. As you add code, your page get more and more stuff. Even you reenter, all is there forever. And all without any designer.

    Third way is Canvas section. More dragging of visual elements we used to, but running it - you will see it is not responsive for various devices and resolutions. Not nice.

    If you are here for desktop applications, all ways are yours, pick any or mix.
    If you tend to nondesktop applications only, or all (desktop + nondesktop), than you need to separate client and server side.
    For client side VFP guys need to use javascript in delegates/methods which web browsers understand. This is bad news for us. VFP is good for server side only.
    We can use only Standard sections or javascript version of Custom section or javascript version of Canvas section for client side.

    Back to demo. Open Lianja Demo (in group Demo Desktop Apps, "lianjademo").
    Click "Custom" in upper part of screen. In this menu click "PHP Custom Section" (5.option). What you are looking at is made by PHP code and this is Way #2.
    Preferred way is #1 (Standard sections), but you are currently eager to see as much PHP code in action as you can, Right?

    You see grey subtitle "This is a PHP custom section"? On the right is the group of 4 icons. Click first (keyboard).
    Editor will open in ppage_section1.php You will see comments explaining steps how to make such a section from scratch.

    I suggest you change code here (or comment existing code) to see what is going on. I am looking at PHP for the first time in my life. I will add a button in step 3

    Code:
    // Step 3: create a "Pageframe" class and add it to the "Section"
    $mysection->addObject("ui_tabs", "Pageframe");
    $mysection->addObject("ui_button", "Commandbutton");

    Then I click in the upper row of screen to 5.icon (sheet of paper). Under grid I get looong button.
    Back to code by clicking "keyboard" icon or 5th icon in first row (pencil)

    Then I try to define button's caption. Ups! $ui_button.text="Click me" is wrong in PHP. Need "->". Ups! need ";" at end.
    Finally I got it.

    Code:
    $ui_button->text="Click me";


    I would then try to remove left listbox by commenting the line with addobject and every mention of ui_listbox.
    5th icon to see it - and there is no listbox. I even did not need to "Desktop App View" to see my changes.

    Code:
    //--------------------------------------------------------------------------
    // Step 6: Add a "Listbox" to the "Container" and set some of its properties
    //$ui_cont->addobject("ui_listbox", "myListbox");
    //$ui_listbox->fixedwidth = 200; 
    //
    ////--------------------------------------------------------------------------
    //// Step 7: Invoke the "Additems" method with a comma separated list of items to add to the Listbox
    //$ui_listbox->additems("All,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");

    You see my point? Try change code in little steps. "Try PHP data access" (8th option from Custom menu).

    After that make new app with PHP as language and on southwind database (Dashboard: Create an App).
    Drag some table (customers) and and Shift+drag (orders). Click + in front customers and click on header of second section of orders. You get all orders of one customer.
    Navigate through customers and see how it is all bound. This is preferred NOCODE way.



    All topics in [Answers] alphabetically: http://www.lianja.com/community/show...p?2717-Answers



  4. #4
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    I created a webview section, with a simple html to try to post to a "hello_world.php". However, it shows the requested page not found.

    Note that the project has been deployed successfully and I verified the file is the the tenant/app folder.
    Next, I try to access the php manually via http://localhost:8001/apps/homeloan/hello_world.php, the file gets downloaded instead of displaying in the browser.
    I tried http://localhost/hello_world.php, without problems.
    i tried http://localhost/apps/homeloan/hello_world.php and it gets downloaded ( a "hello_world.php" gets downloaded)

    A:
    Typically, your browser is going to look for an html page (or in the case of the Lianja Cloud Server, an RSP page).
    I haven't really used PHP in Lianja.
    If you are saying that http://localhost/hello_world.php works in your browser, have you tried this.
    http://localhost/apps/homeloan/hello_world.php ?
    You an double check that your files were deployed properly in
    C:\lianja\cloudserver\tenants\public\wwwroot\apps\ homeloan.

    A2:
    while PHP is enabled for custom webview sections and pages in desktop apps, it is not yet available for scripting on web pages (V6 on the roadmap). Note also a note in the Roadmap indicating that PHP is deprecated from V4.0 onward, and may be removed.




    All topics in [Answers] alphabetically: https://www.lianja.com/community/sho...ll=1#post13748

    These answers are also systematized on the site "Lianja developer": https://lianjadeveloper.wordpress.com/category/php/

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