FrancisChung

LINQ for PHP / JS Developers - Yalinqo & linq.js

Recommended Posts

Does anyone here use a LINQ derivative / port for their projects?

Coming from the .NET World, this is one of the things I miss the most when developing in PHP.
Then I came across these 2 projects.

For PHP : 
https://github.com/Athari/YaLinqo

For JS:

https://github.com/mihaifm/linq

Why I chose those 2 over others :
https://stackoverflow.com/questions/5792388/is-there-something-in-php-equivalent-to-linq-in-c

 

I was wondering if anyone had experience using either one of them AND LINQ in .NET and could share their experiences?

You might wonder why you would use LINQ ? 

The main benefits are better code readability (doing away with if -> then statements),  a unified way of querying data in front and backend (Syntax is SQL derived) and applying paradigms from functional programming (See doing away with if->thens) 

// linq.js - anonymous function
Enumerable.Range(1, 10)
    .where(function(i) { return i % 3 == 0; })
    .select(function(i) { return i * 10; });

 

// Alternative shorter syntax using default variable names
$result2 = from($categories)
    ->orderBy('$v["name"]')
    ->groupJoin(
        from($products)
            ->where('$v["quantity"] > 0')
            ->orderByDescending('$v["quantity"]')
            ->thenBy('$v["name"]'),
        '$v["id"]', '$v["catId"]',
        'array(
            "name" => $v["name"],
            "products" => $e
        )'
    );


 

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By karian
      Hi, based on the work of @microcipcip and @gebeer  (see their posts here and here), I put together a Processwire + React boilerplate (profile).
      Github repo: https://github.com/lapico/process-react

      Cheers,
      K
       
    • By rafaoski
      I would like every new Site Profile like new REGULAR Profile to have modern support for quick creation like browser sync, minify css, js . Something on the style below:
      https://foundationpress.olefredrik.com/
      https://understrap.com/
      One profile that does not have any CSS frontend attached but has the features needed to quickly add eg pagination, comment form, or site menu something like:
      https://roots.io/sage/
      OR
      https://laravel.com/docs/5.5/mix
      I'm not very godd with js but webpack.js meybe is good for this solution ... I would like to know what advanced users in the front end think about this combination and what would be the best ...
       
    • By clsource
      Hello,
      I just want to point out this framework for making html apps https://onsen.io/
      it's compatible with jquery, angular, vue, react or any other js framework.
      So far I made an app using this and bootstrap with https://propeller.in/
      for the desing and some libs like jquery and lodash for the app logic
      I prefer this to other alternatives like ionic since it does not bound you to angular or react.
       
      Cheers
    • By franciccio-ITALIANO
      Hi, I read this and I would like add it to my site.
      https://www.gavick.com/blog/scrollreveal-js-the-easiest-way-to-create-on-scroll-animations
      Excuse me if it's off topic!
      My probem is:
       
      I add the new js file in folder of the site (...assets/js/scrollReveal.js), then I add the code in the html page :

           <!--SCROLL ANIMATION SCRIPTS-->
          <script src="assets/js/scrollReveal.js"></script>
       
      Then I add: data-scroll-reveal="enter from the bottom after 0.9s" near the css class
       
      But the js effect don't start.

      I read this:
      https://www.gavick.com/blog/scrollreveal-js-the-easiest-way-to-create-on-scroll-animations
      where the chef say:
       
      Then, to include library, please open the template/layout/blocks/head.php file and use this code:
      1 $this->API->addJS($this->API->URLtemplate() .'/js/scrollreveal.js');   That’s all you need to do, and the library is now good to go. 
      Now, it's necessary in processwire add that api code in the head.php file?
       
    • By jsantari
      I have some hanna codes that I would like to trigger the inclusion of css and js files depending on the code that is used. Does PW have a way to do this similar to WordPress wp_enqueue_script or style core functions?