# generator-thinkphp

> Yeoman generator for thinkphp

Latest version **0.2.50** (published 2015-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install generator-thinkphp
pnpm add generator-thinkphp
yarn add generator-thinkphp
bun add generator-thinkphp
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.50 |
| Published | 2015-12-16 |
| First published | 2015-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 20 |
| Author | discountry |
| Maintainers | discountry |
| Keywords | yeoman-generator, generator, thinkphp |

## Links

- npm: https://www.npmjs.com/package/generator-thinkphp
- Repository: https://github.com/discountry/generator-thinkphp
- Homepage: https://github.com/discountry/generator-thinkphp#readme
- Issues: https://github.com/discountry/generator-thinkphp/issues
- npm.io page: https://npm.io/package/generator-thinkphp

## Dependencies (6)

- [chalk](https://npm.io/package/chalk.md) ^1.1.1
- [mocha](https://npm.io/package/mocha.md) *
- [lodash](https://npm.io/package/lodash.md) ^3.10.1
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [yeoman-welcome](https://npm.io/package/yeoman-welcome.md) ^1.0.1
- [yeoman-generator](https://npm.io/package/yeoman-generator.md) ^0.20.1

## Recent versions

- 0.2.50 (latest) — 2015-12-16
- 0.2.49 — 2015-12-16
- 0.2.48 — 2015-12-15
- 0.2.45 — 2015-12-15
- 0.2.43 — 2015-12-15
- 0.2.42 — 2015-12-15
- 0.2.41 — 2015-12-15
- 0.2.38 — 2015-09-05
- 0.2.37 — 2015-09-05
- 0.2.36 — 2015-09-05
- 0.2.35 — 2015-09-05
- 0.2.33 — 2015-09-05
- 0.2.32 — 2015-09-05
- 0.2.31 — 2015-09-05
- 0.2.30 — 2015-09-05
- … 17 more at https://npm.io/package/generator-thinkphp/versions

## README

# Thinkphp Generator | Thinkphp 生成器

> 利用yeoman自动构建thinkphp应用 - 通过命令行自动创建应用以及 Controller/Model/View.

[English Doc](/README_en.md)

## 使用方法

安装 `Composer` [关于 composer](https://getcomposer.org/)
```
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
```


安装 `yo` and `generator-thinkphp` [关于 Yeoman](http://yeoman.io/)
```
npm install -g yo generator-thinkphp
```

`cd` 进入到你的工作文件夹以进行下一步操作:
```
cd [workPlace]
```
**`workPlace`是指你平时写代码的文件夹**


输入 `yo thinkphp` 来生成应用，根据指引输入，你可以自定义应用名称，如果你未安装 `Composer` 会有提示是否自动安装:
```
yo thinkphp
```

输入 `cd [appName]` 进入你的应用目录，开始一下步操作:
```
cd [appName]
```
**`appName`是指你自定义应用的名称**


## 自动生成器

已支持的生成器:

* [thinkphp](#app) (aka [thinkphp:app](#app))
* [thinkphp:controller](#controller)
* [thinkphp:model](#model)
* [thinkphp:space](#space)
* [thinkphp:serve](#serve)

### App

创建新的 [ThinkPHP](https://github.com/liu21st/thinkphp) 应用并使用 [Composer](https://getcomposer.org/).

Example:
```bash
yo thinkphp
```

### Controller

为你的应用自动生成新的Controller. 例如 `yo thinkphp:controller [classedName] [spaceName]`.

**`classedName` 为必选项，不能为空.**

**`spaceName` 默认为 `Home` ，可选项.**

Example:
```bash
yo thinkphp:controller Index Home
```

此命令生成 `Application/Home/Controller/IndexController.class.php`:
```php
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {

    public function index(){
    	//
        $this->display();
    }

}
```

以及 `Application/Home/View/Index/index.html`:

```html
<extend name="base" />
<block name="content">
	<h1>Index</h1>
</block>
```

以及 `Application/Home/View/Index/base.html`:

```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Home</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
    <block name="content"></block>
</body>
</html>
```

### Model

和Controller命令基本一样, 为你的应用自动生成新的Model.

Example:
```bash
yo thinkphp:model User Home
```

生成 `Application/Home/Model/UserModel.class.php`:
```php
<?php
namespace Home\Model;
use Think\Model;
class UserModel extends Model {
	//
    protected $tableName = 'User';

}
```

### Space

为你的应用生成新的命名空间. ***命名空间是指thinkphp应用中例如Home/Admin等文件夹***

Example:
```bash
yo thinkphp:space Admin
```

生成 `Application/Admin` 文件夹以及初始内容.

* Admin
	* Common
	* Conf
	* Controller
	* Model
	* View
	* index.html


### Serve

运行本地的php测试服务器，此功能例如php自带的测试服务器实现.

Example:
```bash
yo thinkphp:serve
```

你的测试服务器运行在 127.0.0.1:3000.

## 关于

Thinkphp的命令行自动构建工具，类似 [Laravel](http://laravel.com) 的 `php artisan`

## 许可证

[MIT](/LICENSE)

---
_Source: https://npm.io/package/generator-thinkphp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
