Giter VIP home page Giter VIP logo

ufa's Introduction

UFA Introduction

UFA: Uniform Frontend Archiecture. A PHP composer plugin.

How to use?

  1. To add it in your composer.json.
{
    "require": {
        "angejia/ufa": "0.3.*",
    },
    "repositories": {
        "ufa": {
            "type": "git",
            "url": "[email protected]:frontend/ufa.git"
        }
    }
}

If this step success, you can find the vendor/angejia/ufa/ folder under your project.

  1. To add ufa as a service in your config/app.php.
return [
    'providers' => [
        ...

        `Angejia\Ufa\Providers\UfaServiceProvider::class,`

        ...
    ]
]

After this step, you can use it anywhere without error, such as ufa()->extJs() or ufa()->extCss() .etc.

Note: although it has no error but it still do nothing in your html. In other words, it doesn't include any styles or scripts when your page loading. It won't work, unless you finish next step.

  1. To add ufa views in your config/view.php and include ufa styles & ufa scripts in your HTML blade view.
return [
   'paths' => [
       realpath(base_path('resources/views')),// default
       realpath(base_path('../vendor/angejia/ufa/src/views'))//ufa views folder
   ],
]

Add ufa styles and ufa/scripts, for example:

<!DOCTYPE html>
<html>
    <head>
        @include('resources.styles')
    </head>
    <body>
        <!-- main content -->
        @include('resources.styles')
    </body>    
</html>

And untill now, the ufa()->extJs and ufa()->extCss works as you expected.

API List

You can use all the following function as this: ufa()->asset('image/home.jpg').

  • extJs($data = [])
<?php
ufa()->extJs([
    'home.js',
    '../lib/jquery.js'
])
  • extCss($data = [])
<?php
ufa()->extJs([
    'home.css',
    '../lib/jquery-ui.css'
])
  • asset($data = [])
<div>
    <img src="{{ufa()->asset('image/logo.png')}}"/>
</div>
  • addParam($value = [], $key = '')
<?php
ufa()->addParam(['count' => $count, 'pagename' => $page_name]);
  • getParam($key)

Get single parameter.

  • getParams()

Get all parameters.

ufa's People

Watchers

James Cloos 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.