jaxon-php/jaxon-yii 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jaxon-php/jaxon-yii

最新稳定版本:v5.0.0-beta.1

Composer 安装命令:

composer require jaxon-php/jaxon-yii

包简介

Jaxon library integration for the Yii Framework

README 文档

README

This package integrates the Jaxon library into the Yii framework. It requires the version 2.0.11 or newer.

Installation

Add the following lines in the composer.json file, and run the composer update command.

"require": {
    "jaxon-php/jaxon-yii": "^4.0"
}

Or run the composer require jaxon-php/jaxon-yii command.

This package provides a filter that must be attached to routes to pages where the Jaxon features are enabled.

This is an example of a Yii controller using the Jaxon library.

namespace app\controllers;

use Yii;
use yii\web\Controller;
use Jaxon\Yii\Filter\JaxonConfigFilter;

class DemoController extends Controller
{
    public function behaviors()
    {
        return [
            [
                'class' => JaxonConfigFilter::class,
                'only' => ['index', 'jaxon'],
            ],
        ];
    }

    /**
     * Process Jaxon ajax requests. This route must be the same that is set in the Jaxon config.
     */
    public function actionJaxon()
    {
        $jaxon = jaxon()->app();
        if(!$jaxon->canProcessRequest())
        {
            // Jaxon failed to find a plugin to process the request
            return; // Todo: return an error message
        }

        return $jaxon->processRequest();
    }

    /**
     * Insert Jaxon js and css codes in the page.
     */
    public function actionIndex()
    {
        // Set the layout
        $this->layout = 'demo';
        // Get the Jaxon module
        $jaxon = jaxon()->app();

        return $this->render('index', [
            'jaxonCss' => $jaxon->css(),
            'jaxonJs' => $jaxon->js(),
            'jaxonScript' => $jaxon->script()
        ]);
    }
}

Before it prints the page, the controller calls the $jaxon->css(), $jaxon->js() and $jaxon->script() functions, to get the CSS and javascript codes generated by Jaxon which are inserted into the page.

Configuration

The Jaxon library settings are defined in the @app/config/jaxon.php file, and separated into two sections. The options in the lib section are those of the Jaxon core library, while the options in the app sections are those of the Jaxon application.

The following options can be defined in the app section of the config file.

Name Description
directories An array of directory containing Jaxon application classes
views An array of directory containing Jaxon application views

By default, the views array is empty. Views are rendered from the framework default location. There's a single entry in the directories array with the following values.

Name Default value Description
directory @app/jaxon/classes The directory of the Jaxon classes
namespace \Jaxon\App The namespace of the Jaxon classes
separator . The separator in Jaxon class names
protected empty array Prevent Jaxon from exporting some methods

Usage

The Jaxon classes

The Jaxon classes can inherit from \Jaxon\App\CallableClass. By default, they are located in the @app/jaxon/ajax dir of the Yii application, and the associated namespace is \Jaxon\Ajax.

This is an example of a Jaxon class, defined in the @app/jaxon/ajax/HelloWorld.php file.

namespace Jaxon\Ajax;

class HelloWorld extends \Jaxon\App\CallableClass
{
    public function sayHello()
    {
        $this->response->assign('div2', 'innerHTML', 'Hello World!');
    }
}

Contribute

  • Issue Tracker: github.com/jaxon-php/jaxon-yii/issues
  • Source Code: github.com/jaxon-php/jaxon-yii

License

The package is licensed under the BSD license.

统计信息

  • 总下载量: 1.58k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-06-15