[PHP] Solutions to environment variable setting and data table problems

Source: Internet
Author: User
[PHP] environment variable setting and data table problems solution preface

I have been in touch with PHP for a while. There are many problems in the setup environment and the running of the first Api project. here I will analyze these problems and propose corresponding solutions.

Questions and thoughts about the framework installation guide in Windows.

Generally, the instructor will give you the framework installation guide based on your installation environment. for new users, the framework installation is also difficult.

Wnmp

The installation of wnmp in the first step of building a development environment for Windows may encounter problems. one step is to configure: add the directory where php.exe is located to the environment variable. The new term "environment variable" appears ". Let's take a look at the concept of environment variables: environment variables are an object with a specific name in the operating system. they contain information that one or more applications will use. For example, in Windows and DOS operating systems, when the system is required to run a program without telling it the complete path, the system not only looks for this program under the current directory, you should also find the path specified in the path. You can set environment variables to better run processes (from Baidu Encyclopedia ). That is to say, adding environment variables allows the application to be used in various places on your computer.

To add environment variables, right-click my computer> Advanced System Settings> environment variables> select the Path variable in the system variables> select the php.exe file under the wnmp installation directory.

VPN

There are many VPN options, but in fact, VPN is not used many times at the beginning, but in the long run, VPN is very important. I recommend three VPNs to help you:

1. Shadowsocks this is a paid VPN, because it is paid, so stability can be guaranteed, but as far as I know, Shadowsocks can only be used for websites, not for clients and other applications that leave the website.

2. blue light/lantern This is a free wall flip software that is very easy to use. after downloading and unzipping it, double-clicking it will directly access websites such as Google, but its instability also exists, however, it is very convenient for me to use it to overturn the wall. You can download it directly from Baidu, with many resources. here we also post a blue light address hosted on GitHub provided to me by our team lead. : Lantern

3. the third is the Yunti provided by our technical team. I think the Yunti is good in all walks of life. if you need it, ask the relevant personnel of the technical team for an account, this depends on your choice.

Composer

The installation of composer is smooth, but under the default installation conditions, I cannot find his installation directory. if you have such questions, you can try the address I provided, check whether C: \ ProgramData \ ComposerSetup \ bin is correct.

Problems and Solutions for Api project operation

At the beginning, you need to know a lot of knowledge about how to see the successful operation of the api project in the browser. For example, database creation, modification of routes and controllers, configuration of nginx conf, addition of data to data tables, and modification of controllers to display data. The problems and solutions I know are listed below.

Switch the development branch of the Git branch

This step is the most important. do not operate on the master branch, which will cause unnecessary trouble. For specific operations and principles, see the use of git on the site: Git collaborative development project Guide

Create database

Since we have installed wnmp, we can directly run mysql.exe in the third column on the right: Open MariaDB Shell to create our database. But remember, the database must be created in the project directory. that is to say, I clone the api project to F: \ project \ api, then the database should be created in this directory. We can switch to disk F first, and then cdF: \ project \ api. You can also search for these items by yourself. let's talk about them directly.

The code for creating a database is as follows (the name of the database created by ciji for you ):

Create database ciji; use database: use ciji;

View database: show ciji;

Modify data in a data table

When the api project runs successfully, the next task is to enter data in the table and display the data in the browser. This modification is based on the data in the users table filled in to the DatabaseSeeder. php file, the method can be found on the website I provided, and specifically introduces what Seeder is and what is used. Seeder automatically fills in test data (ps: note how much data you have and how much data you have)

DB::insert('insert into        users(id, mobile,email,password,secret,nickname,avatar_url)        values (?, ?,?,?,?,?,?)',        ['1', '13587711073', 'a@qq.com', '232411', '0', 'jack', '123'] 

Because the route we use calls the test method of ApitestController, we need to modify the data in the ApitestController file after modifying the Seeder data, for details about how to modify the settings, refer to the database in Laravel's official documentation. Here I will give the connection and my code, of course, not limited to my method. Laravel official documentation

 get();     return $users;  }} 

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.