Install and use laravel-u-editor by composer, and use composer by laravel.

Source: Internet
Author: User
Tags composer install csrf attack

Install and use laravel-u-editor by composer, and use composer by laravel.

  Preface

The framework used is laravel5.1, which is built by composer. You can directly configure composer. If it is not set up by composer, you need to install composer first. For details about the installation and release, refer to the composer official website of China,

It is best to configure a Chinese Image in China. Otherwise, it is likely that the download of resources will fail and various problems will occur.

   Install composer

  1. Configure the composer. json file and add it to the require in the composer. json File 

"stevenyangecho/laravel-u-editor": "~1.4"

  2. Run composer update or composer install on the command card (this can be used to run global variables that require composer configuration anywhere)

Composer update or run composer install

Without an accident, you will be downloading the files required by the rich text editor, as well as other unexpected situations, such as php extension problems,

This is a fileinfo extension used to upload rich text files. If it is not installed, you only need to install it in php. remove the semicolon comment before the extension in the INI file and restart the service.

extension=php_fileinfo.dll

   

 3. Configure the config/app. php file

   Add

Stevenyangecho\UEditor\UEditorServiceProvider::class

Add

  'UEditor'=>Stevenyangecho\UEditor\UEditorServiceProvider::class

4. register the tool interface and run it on the command line

php artisan vendor:publish

 

The laravel-u-editor Rich Text editor has been installed. You can go to the config directory of the project to check whether it is UEditorUpload. php file. This is the configuration file of the Rich Text Editor. You can configure the File Upload path.

5. Use the editor

① Introduce in the view

<div id="ueditor" class="edui-default">    @include('UEditor::head')</div>

② Add the following code where the editor is needed

<div id="ueditor" class="edui-default">    @include('UEditor::head')</div>

③ Add the js file and add the following code at the end of the View

@ Section ('script') <script id = "ueditor"> </script> <script> var ue = UE. getEditor ("ueditor"); ue. ready (function () {// because Laravel has anti-csrf attack processing, add the ue.exe cCommand ('serverparam', '_ token ', '{{ csrf_token () }}') ;}); </script> @ stop

 

    

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.