Laravel-admin JSON file operation

Source: Internet
Author: User
Tags custom name

Demand:

1. Read the content within the JSON file;

2. Iterate and insert the JSON content after the read into the database according to the requirements.

Operation Steps:

1. Create a. php file with a custom name in the \app\console\commands directory in the Laravel project.

2. The following trip requires special attention, which is the statement that the command executes:

$signature = 'category';

3. Write the corresponding logical code according to your own needs:

to read the contents of a file into a string :

$ Variable name = file_get_contents (' *.json ');

convert JSON data to an array :

Json_decode ($category, true);

4. Test code is correct command:

The $signature variable Value "category" that is filled in in PHP artisan +2.


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.