承接 windwalker/controller 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

windwalker/controller

Composer 安装命令:

composer require windwalker/controller

包简介

Windwalker Controller package

README 文档

README

The Windwalker Controller package is a simple interface to control some business logic, id didn't dependency to any other packages. You may integrate it to any systems.

Installation via Composer

Add this to the require block in your composer.json.

{
    "require": {
        "windwalker/controller": "~2.0"
    }
}

Create Your Controller

use Windwalker\Controller\Controller;

class IndexController extends AbstractController
{
    public function execute()
    {
        return 'Index';
    }
}

$controller = new IndexController;

$output = $contorller->execute();

Windwakler Controller is a "Single Action Controller", follows single responsibility principle, every controller just maintain one task(action). It is inspired from Joomla New MVC. You can create IndexController, CreateController, UpdateController and DeleteController for CRUD.

Using Input and Application

By default, controller maintains an input and an application object. We can set it when construct:

use Windwalker\Controller\Controller;

class IndexController extends AbstractController
{
    public function execute()
    {
        // Get params from http request
        $method = $this->input->get('_method');

        $this->app->redirect('...');

        return true;
    }
}

$input = new Input;
$app = new WebApplication;

$controller = new IndexController($input, $app);

$output = $contorller->execute();

It didn't dependency to Windwalker self, you can push other framework's input and application into it:

$input = new Request;
$app = new HttpKernel;

$controller = new IndexController($input, $app);

$output = $contorller->execute();

HMVC

Using HMVC in Windwalker controller is very easy:

class IndexController extends AbstractController
{
    public function execute()
    {
        $this->input->set('id', 123);

        $foo = new FooController($this->input, $this->app);

        echo $foo->execute();

        return true;
    }
}

Multi Action Controller

If you are familiar to common multiple action pattern, use AbstractMultiActionController:

use Windwalker\Controller\AbstractMultiActionController;

class ArticleController extends AbstractMultiActionController
{
    public function indexAction()
    {}

    public function saveAction($id = null, $data = array())
    {}

    public function deleteAction($id = null)
    {}
}

$controller = new ArticleController;

// Will call saveAction()
$controller->setActionName('save')
    ->setArguments(array(5, $data))
    ->execute();

If no action set, will call doExecute() instead, but you still need to override doExecute() first.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-2.0
  • 更新时间: 2014-09-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固