How to debug WeChat locally

Source: Internet
Author: User
In general, web pages need to be published to the Internet, and it is extremely difficult to use a complex publishing system. our front-end dogs are also unable to speak out, even if FTP is one time convenient, however, this is an unscientific (elegant) method. For existing online versions, no one dared to roll over to the Internet before the development and testing are complete. In the traditional desktop web development process, after local development is completed, the link is to test the joint debugging, so let's talk about how to configure the HOST for the device.

How to perform local debugging for development?

Pretend to be invited. recently, the team encountered similar problems and shared some experience.

Just talk about local debugging.
In general, web pages need to be published to the Internet, and it is extremely difficult to use a complex publishing system. our front-end dogs are also unable to speak out, even if FTP is one time convenient, however, this is an unscientific (elegant) method. For existing online versions, no one dared to roll over to the Internet before the development and testing are complete.
In the traditional desktop web development process, after local development is completed, the link is to test the joint debugging, so let's talk about how to configure the HOST for the device.

1. configure the HOST for the device

The farthest distance in the world, you are on the Internet, and I am in the testing environment.

Modifying the HOST file of a device is an advanced (abnormal) method, so you do not have the permission to change it by default. However, after the iOS device is jailbroken and the Android device is root, you will be able to mess up it. the application dedicated to modifying the host file is also a search engine, the premise is that you have to jailbreak the device and root the device.
Here we will only talk about how to configure a HOST for the device without jailbreak or root.
The main idea is to use a host as the proxy server. the mobile phone is connected through an HTTP proxy, and all the HTTP requests on the mobile phone are forwarded by the host proxy, in this way, you only need to change the HOST of the HOST.
The Team is only me and @ xzheng. we are both MacbookPro's cool dog and the platform is relatively unified, so it is easier to do it.
The tools we use:

  • One iMac connected to WiFi

  • Any number of mobile devices connected to the same Wi-Fi network segment, iOS or Android Unlimited

  • Application Charles (Charles Web Debugging Proxy • HTTP Monitor/HTTP Proxy/HTTPS & SSL Proxy/Reverse Proxy) used to enable Proxy service and packet capture)

  • HOST management application Gas Mask (2 ndalpha/gasmask · GitHub)

The main steps are as follows:

  1. Connect both the iMac and the device to the same WiFi and ensure that they are in the same network segment. for example:
    IMac 192.168.1.88
    IPhone 192.168.1.101

  2. Use Charles to open the iMac proxy service and capture packets


  3. Set the device HTTP proxy to manual. the server address is the iMac IP address. the default port number is 8888.



  4. Use Gas Mask to modify the iMac HOST file



Therefore, the entire process looks like this:
This is a benefit of mentioning that many JS APIs in the built-in Webview need to apply for permissions, and (theoretically) the domain name where the current URL is located will be checked for permissions. Therefore, if the methods of these APIs cannot be called without the domain name that is consistent with the real environment of the Internet, the HOST can avoid this problem.
Above, all http://dianhua.qq.com on mobile phoneAll requests are sent to the HOST through Charles's proxy, because the HOST is modified HOST, http://dianhua.qq.comThe request is indirectly transferred to the IP address set in the HOST file.

2. local debugging
I am happy to see Zend Studio mentioned by the subject again and again. The PHP dog and HOST are all fixed, and local debugging is not simple yet:

  1. Connect the HTTP proxy to the host as mentioned above

  2. Start a local environment on the host and ask which PHP environment is strong. I silently disabled XAMPP.

  3. Change HOST to http://dianhua.qq.com 127.0.0.1

The entire process is as follows:


Above, http://dianhua.qq.com on mobile phoneThe requests are routed to the htdoc Directory of the HOST under the influence of the HOST file.
Save it here and refresh it over there. ba shi is crying badly.

The above example is a Mac environment. in Windows, the combination of Fiddler and Willow is the same. you can try it if necessary.

This is our practice and we hope it will be useful to the subject.

The above describes how to perform local debugging. For more information, see other related articles on php Chinese network!

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.