Skip to content
Joe Huss edited this page Nov 11, 2022 · 5 revisions

Welcome to the webman wiki!

This is webman with the following changes:

  • added webman/console
  • added yzh52521/webman-lock

webman/console docs

Instructions
./webman 命令 or php webman 命令
E.g ./webman version or php webman version

print webman version number

print the current routing configuration

Create a controller file
E.g ./webman make:controller adminwill create a app/controller/Admin.php
E.g ./webman make:controller api/userwill create a app/api/controller/User.php

Create a model file
E.g ./webman make:model adminwill create a app/model/Admin.php
E.g ./webman make:model api/userwill create a app/api/model/User.php

Create a middleware file
E.g ./webman make:middleware Authwill create a app/middleware/Auth.php

Create custom command file
E.g ./webman make:command db:configwill create a app\command\DbConfigCommand.php

Create a plugin project
E.g ./webman plugin:create foo/adminwill create config/plugin/foo/admin and vendor/foo/admintwo directories
See Creating Plugins

Export plugin project
E.g ./webman plugin:export foo/admin
See Creating Plugins

Users can define their own commands, for example the following is the command to print the database configuration

  • implement ./webman make:command config:mysql
  • Open app/command/ConfigMySQLCommand.phpModified as follows

command line run php webman config:mysql

The result is similar to the following:

+-------+---------+--------+-----------+------+----------+----------+----------+-------------+---------+-----------------+--------+--------+--------+--------+---------+
| name  | default | driver | host      | port | database | username | password | unix_socket | charset | collation       | prefix | strict | engine | schema | sslmode |
+-------+---------+--------+-----------+------+----------+----------+----------+-------------+---------+-----------------+--------+--------+--------+--------+---------+
| mysql | true    | mysql  | 127.0.0.1 | 3306 | mysql    | root     | ******   |             | utf8    | utf8_unicode_ci |        | 1      |        |        |         |
+-------+---------+--------+-----------+------+----------+----------+----------+-------------+---------+-----------------+--------+--------+--------+--------+---------+

symfony/console docs

yzh52521/webman-lock docs

<?php

namespace app\controller;

use yzh52521\WebmanLock\Locker;

class Cash {
    public function changeCash()
    {
        $lock = Locker::lock($key);
        if (!$lock->acquire()) {
            throw new \Exception('操作太频繁,请稍后再试');
        }
        try {
            // 修改用户金额
        } finally {
            $lock->release();
        }
        return 'ok';
    }
}

More operation reference: symfony/lock documentation

Clone this wiki locally