PHP code example of hahadu / think-editor

1. Go to this page and download the library: Download hahadu/think-editor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hahadu / think-editor example snippets


use Hahadu\ThinkEditor\Client\WangEditor;
$wE = new WangEditor();

//服务端配置
$config = [
        'disk' => 'public', //filesystem 中的disk配置 默认public
     //   'putFilePath' => 'files', //disk/url目录的下级目录,不设置则根据文件类型自动选择
        'upValidate'=> [ //上传文件验证规则
            'fileSize:10240000', //默认上传限制10M php.ini调整上传大小
            //'fileExt:jpg,png,gif,mp4', //允许上传的文件格式
        ],

        'water' => [ //水印设置
            'add_water_type' => 1, //添加水印 0不添加水印,1添加文字水印,2添加图片水印
        ],
        'base64' => [ //base64文件上传设置
            'extName' => 'jpg', //缓存名字后缀
        ],

];

$fileFiled = 'files'; // 文件上传表单名称
return $wE->uploader($fileFiled);

//假设提交文本内容的表单名称为content
$content = request()->post('content');

echo $wE->base64Img($content);

use Hahadu\ThinkEditor\Client\UEditor;
$UE = new UEditor();
return $UE->ueditor();