You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

generator-thinkphp

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generator-thinkphp

Yeoman generator for thinkphp

Source
npmnpm
Version
0.2.38
Version published
Weekly downloads
37
311.11%
Maintainers
1
Weekly downloads
 
Created
Source

generator-thinkphp

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

Generators

Available generators:

App

Create a new project using ThinkPHP and using Composer.

Example:

yo thinkphp

Controller

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/index.html:

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

Produces app/Home/View/base.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

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'; 

}

Space

Create a new namespace folder for you app.

Example:

yo thinkphp:space Admin

Produces app/Admin folder and default files in your project.

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

Serve

Run a PHP Test Server locally.

Example:

yo thinkphp:serve 

And you'll get a php server running at 127.0.0.1:3000.

About

Add command line tools for ThinkPHP. Just like Laravel's php artisan

License

MIT

Keywords

yeoman-generator

FAQs

Package last updated on 05 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts