I’ve be planning to work on this project for a long time. Laravel has a feature php artisan
which is very helpful for developers. I really want to add the “generator” feature for ThinkPHP. which is a very popular framework in China.
Finally, this yeoman-thinkphp generator came out. It’s just a preview version of my idea but it’s really cool and somehow helpful for your development with ThinkPHP.
A lot of TODOs still waiting for me. :P
Yeoman generator for ThinkPHP - Create ThinkPHP Project and generate Controller/Model/View for it.
##Usage
Install Composer
Read more about composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Install yo
and generator-thinkphp
Read more about Yeoman
npm install -g yo generator-thinkphp
Make a new directory, and cd
into it:
mkdir my-new-project && cd $_
Run yo thinkphp
to init your project, and follow the steps:
yo thinkphp
Available generators:
Create a new project using ThinkPHP and using Composer.
Example:
yo thinkphp
Generates a controller and view for your app. Command like
yo thinkphp:controller [classedName] [spaceName]
The classedName
is required value, without it will get error.
The default spaceName
is Home
and it’s optional.
Example:
yo thinkphp:controller Index Home
Produces app/Home/Controller/IndexController.class.php
:
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
//
$this->display();
}
}
Produces app/Home/View/index.html
:
<extend name="base" />
<block name="content">
<h1>Index</h1>
</block>
Much like Controller generator, it generates a plain model for your Project.
Example:
yo thinkphp:model User Home
Produces app/Home/Model/UserModel.class.php
:
<?php
namespace Home\Model;
use Think\Model;
class UserModel extends Model {
//
protected $tableName = 'User';
}
Create a new namespace folder for you app.
Example:
yo thinkphp:space Admin
Produces app/Admin
folder and default files in your project.
Add command line tools for ThinkPHP. Just like Laravel’s php artisan
MIT
Back To Top