Giter VIP home page Giter VIP logo

leaf-ui's Introduction




Leaf UI [WIP v0.2.0]

Leaf UI is a PHP library for building user interfaces.

Leaf UI doesn't need a new compiler or any extensive compiling, it's just the same old PHP you write everyday; as such, you can build full scalable Leaf UI powered apps or just sprinkle Leaf UI into your existing HTML/PHP code.

v0.2.0 of Leaf UI is currently in development. It's a complete rewrite of the library and will be released soon. It comes with a lot of new features and a new API. Leaf UI v0.2.0 will allow you to build full scalable Leaf UI powered apps, write reactive UIs all in PHP. You can think of it as a PHP version of React.

Installing Leaf UI

Like most PHP libraries, we recommend installing Leaf UI with composer. Just open up your console and type:

composer require leafs/ui

Or install the next version of Leaf UI:

composer require leafs/ui@dev-next

This will install Leaf UI into your application. You don't have to worry about bloating your application: Leaf UI has no external dependencies.

After this, you can use all of Leaf UI's methods and components.

View the documentation here

Building your first Leaf UI

Since Leaf UI is modelled after React, everything is a component. You can create your own components and handle your application state in them.

<?php

use Leaf\UI\Core;
use Leaf\UI\Component;

class Test2 extends Component
{
    public $count = 1;

    public function increment()
    {
        $this->count = $this->count + 1;
    }

    public function decrement()
    {
        $this->count = $this->count - 1;
    }

    public function render()
    {
        return Core::createElement('body', [], [
            Core::createElement('div', [], [
                Core::createElement('div', [], 'Static text'),
                Core::createElement('button', ['@click' => 'decrement'], '-'),
                Core::createElement('h1', [], $this->count),
                Core::createElement('button', ['@click' => 'increment'], '+'),
            ]),
        ]);
    }
}

This component renders some static text, a button to decrement a counter, a counter and a button to increment the counter. The counter is stored in the component's state and is updated when the buttons are clicked.

To actually make this work, you simply need to render this component wherever you want it to appear.

<?php

use Leaf\UI\Core;

require_once __DIR__ . '/vendor/autoload.php';

echo Core::render(new Test2());

The most beautiful part about all this is that it can run outside Leaf. It is completely independent of Leaf and can be used in any PHP application.

This file is still being updated!

๐Ÿ’ฌ Stay In Touch

๐Ÿ““ Learning Leaf 3

  • Leaf has a very easy to understand documentation which contains information on all operations in Leaf.
  • You can also check out our youtube channel which has video tutorials on different topics
  • We are also working on codelabs which will bring hands-on tutorials you can follow and contribute to.

๐Ÿ˜‡ Contributing

We are glad to have you. All contributions are welcome! To get started, familiarize yourself with our contribution guide and you'll be ready to make your first pull request ๐Ÿš€.

To report a security vulnerability, you can reach out to @mychidarko or @leafphp on twitter. We will coordinate the fix and eventually commit the solution in this project.

Code contributors


Michael Darko

๐Ÿคฉ Sponsoring Leaf

Your cash contributions go a long way to help us make Leaf even better for you. You can sponsor Leaf and any of our packages on open collective or check the contribution page for a list of ways to contribute.

And to all our existing cash/code contributors, we love you all โค๏ธ

View the sponsors page to see all our sponsors.

๐Ÿคฏ Links/Projects

leaf-ui's People

Contributors

mychidarko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.