Ci框架代码提示

1.https://github.com/topdown/phpStorm-CC-Helpers

2.External Libraries上右键->Configure PHP Include Path

3.system/core Controller.php Model.php database/DB_query_builder.php 选中3个核心文件->右键->Mark as Plain Text

4.新建 application/controllers/test/Cli.php

<?php
	defined('BASEPATH') or exit('No direct script access allowed');

	class Cli extends CI_Controller {
	    function filename($path=APPPATH . 'models/', $exten = '.php', $ifchild = true){
	        static $file_array=array();
	        $path = preg_replace('/(.*)([^\/])$/', '$1$2/', $path);
	        if (is_dir($path)) {
	            $H = @ opendir($path);
	            while(false !== ($_file=readdir($H))){
	                if(is_dir($path.$_file) && $_file != "." && $_file!=".."){
	                    if($ifchild){
	                        $this->filename($path.$_file, $exten ,$ifchild);
	                    }
	                }elseif(is_file($path.$_file) && $_file!="." && $_file!=".."){
	                    if($exten == '*'){
	                        array_push($file_array, $_file);
	                    } else {
	                        if(preg_match('/(.*)'.$exten.'/', '/'.$_file.'/')){
	                            array_push($file_array, $_file);
	                        }
	                    }
	                }
	            }
	            closedir($H);
	        }
	        $array = $file_array;

	        return $array;
	    }

	    function create_my_models(){
	        $content_header = <<< 'str'
	<?php die();

	/**
	 * Add you custom models here that you are loading in your controllers
	 *
	 * <code>
	 * $this->site_model->get_records()
	 * </code>
	 * Where site_model is the model Class
	 *
	 * ---------------------- Models to Load ----------------------
	 * <examples>
	 *
	str;
	        $content_ender = <<< 'str'
	  */
	class my_models
	{
	}

	// End my_models.php
	str;
	        $my_modes_full_path = './my_models.php';
	        if(!file_exists($my_modes_full_path)){
	            if($fp=fopen($my_modes_full_path,'w')){
	                fwrite($fp,$content_header);
	            } else {
	                echo '创建文件失败, 请检查是否为权限不足!' . PHP_EOL;
	                exit();
	            }
	        } else {
	            echo '文件已存在!' . PHP_EOL;
	            exit();
	        }
	        $model_path   = APPPATH . 'models/';
	        $library_path = APPPATH . 'libraries/';

	        $model_filenames  = $this->filename($model_path);
	        $library_filenames = $this->filename($library_path);
	        
	        // 去重(也可以不操作去重,不过生成的文件会有红线)
	        $filenames = array_merge($model_filenames, $library_filenames);
	        $filenames = array_flip($filenames);
	        $filenames = array_keys($filenames);

	        $line = '';
	        foreach ($filenames as $filename) {
	            $filename = str_replace(strrchr($filename, "."),"",$filename);
	            $line .= '* @property ' . $filename .' $'. $filename . "\r\n";
	        }
	        fwrite($fp,$line);
	        fwrite($fp,$content_ender);
	        fclose($fp);
	    }

	}

5.项目根目录 php index.php test/cli create_my_models

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值